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 represents 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, the 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 the 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 The author writes on AI 1
102 Mahesh Chand The author writes on C# 1
103 David McCarter The author writes on .NET 1
104 Raj Kumar The 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
1004      

The Person table stores information about person types. Each record in a table represents a person. One example of a person is an Author. The author's table stores information about the 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.

The book's table lists books written by an author. The book 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 the above tabular data in a hierarchical form with their parent and level.

Hierarchical Database Model

History of hierarchical databases

The hierarchical format was introduced by IBM in the 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 loaded 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 relationship format. Major several programming languages provide the functionality to read tree structure databases.
  • Easy to understand due to its one-to-many relationships. 

The key disadvantages of hierarchical databases are

  • It’s the rigid format of one-to-many relationships. That means it doesn’t allow more than one parent of a child.
  • Multiple nodes with the same parent will add redundant data.
  • Moving one record from one level to another 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 real-world use cases of a hierarchical database system.

XML and XAML are two more popular and most widely used data storages that are based on hierarchical data models. 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 the 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.

Here are some more articles that you may be interested in:

  1. What Are Different Types of Database Management Systems
  2. What are Hierarchical Databases
  3. What are Relational Databases
  4. What are Graph Databases
  5. What are Network Databases
  6. What are Document Databases
  7. What are NoSQL Databases
  8. What are Column Store Databases
  9. What is SQL
  10. What are the Most Popular Databases in the World

References


Similar Articles
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.