What is a Hierarchical Database

Hierarchical database

A database stores digital data. A database management system (DBMS) is a software system that uses a standard method to store and organize data. A DBMS allows a mechanism to access, insert, update, and delete data via tools, queries, and programs. There are several types of database management systems such as relational, network, graph, and hierarchical. Learn more about Different Types of Database Management Systems.
A hierarchical database is DBMS that represent data in a tree-like form. The relationship between records is one-to-many. That means, one parent node can have many child nodes. A hierarchical database model is a data model where data is stored as records but linked in a tree-like structure with the help of a parent and level. Each record has only one parent. The first record of the data model is a root record
In the following diagram, Author is the root node. The root node has 4 children.
Hierarchical Database 
The root record is always on level 0 and is the first element to be traversed in the data model. The next level children of the root record are Level 1 and have root as their parent. The next level is Level 2 and so on.
Let's look at the following 3 database tables - Person, Authors, and Books.
<>Person Table      
<>ID Role Description ParentID
1 Author Writes, speaks, trains 0
Authors Table      
ID Name Description ParentID
101 Allen O'Neill Author writes on AI 1
102 Mahesh Chand Author writes on C# 1
103 David McCarter Author writes on .NET 1
104 Raj Kumar Author writes on AWS 1
Books Table      
ID Topic Title ParentID
1001 ADO.NET ADO.NET Programming 102
1002 GDI+ Programming GDI+ 102
1003 C# Learn C# 8.0 102
The Person table stores information about person types. Each record in a table represents a person. One example of a person is an Author. Authors table stores information about authors. An author has an ID, name, description, and Parent ID.
The Parent ID links an author to a parent, person. An author can have only one parent.
Books table lists books written by an author. The books table has ID, Topic, Title, and ParentID. The ParentID is the link between the author and the books.
In some cases, a single table can represent data from all tables by simply linking records with their parent IDs.
The following tree diagram represents above tabular data into a hierarchical form with their parent and level.
Hierarchical Database Model 

History of hierarchical databases

Hierarchical format was introduced by IBM in 1960s for mainframe systems. Mainframe computers still use hierarchical databases. IBM IMS is one of the most popular databases. IMS uses blocks of data known as segments. Each segment can contain several pieces of data, which are called fields. Each segment can be load and read into computer memory from the database.

Advantages of hierarchical databases

Hierarchical databases are useful when you need to represent data in a tree like hierarchy. The perfect example of a hierarchical data model is the navigation file or sitemap of a Website. A company organization chart is another example of a hierarchical database.
The key advantages of hierarchical databases are: 
  • Traversing through a tree structure is very simple and fast due to its one-to-many relationships format. Major several programming languages provide functionality to read tree structure databases.
  • Easy to understand due to its one-to-many relationships. 
Key disadvantages of hierarchical databases are: 
  • It’s rigid format of one-to-many relationships. That means, it doesn’t allow more than one parent of a child.
  • Multiple nodes with same parent will add redundant data.
  • Moving one record from one level to other level could be challenging.

Popular hierarchical databases

The most popular hierarchical databases are IBM Information Management System (IMS) and RDM Mobile. Windows Registry is another example of a real-world use cases of a hierarchical database system.
XML and XAML are two more popular and most widely use data storages that are based on hierarchical data model. In XML and XAML, each file starts with a root node that may be one or more child nodes. Each child node again can have one or more child nodes and so on.
The following is an example of an XML file where catalog is the root node.
Hierarchical XML Database
A website sitemap is another example of a hierarchical data model that is used by webmasters and Google search to identify the content of websites.