What is the Difference Between Relational and Hierarchical Database

The main difference between relational and hierarchical database is that the relational database follows the relational model and stores data in tables while the hierarchical database follows hierarchical model and stores data in tree-like structure. 

A database is a collection of related data. DBMS is a software that helps to store data in a database in a way that is easier to store, access and manage. There are various types of databases, and relational and hierarchical databases are two of them.

Key Areas Covered

1. What is a Relational Database
     – Definition, Functionality
2. What is a Hierarchical Database
     – Definition, Functionality
3. What is the Difference Between Relational and Hierarchical Database
     – Comparison of Key Differences

Key Terms

Database, DBMS, Hierarchical Database, Relational Database

Difference Between Relational and Hierarchical Database - Comparison Summary

What is a Relational Database

A database model defines the logical design and the structure of a database. Where, a relational database is based on the relational model, and stores data in tables. Moreover, the rows represent each entity while the columns represent the attributes.

Difference Between Relational and Hierarchical Database_Figure 1

Figure 1: A Table in Relational Database

For example, assume a database in an organization. The employee table has the attributes emp-id, name, age, and city. Here, the primary key of the employee table is the emp-id. Another table called project table has the attributes project-id, project-name, duration and emp-id. Here, the primary key of the project table is project-id. The emp-id in the employee table is a foreign key in the project table. These two tables are associated with each other using the foreign key. Therefore, the tables in a relational database are connected to each other.

Structured Query Language (SQL) is used to store and manage data in a relational database. SQL divides further into three main categories: Data Definition Language (DDL), Data Manipulation Language (DML) and Data Control Language (DCL). Furthermore, DDL changes the structure of the tables. DML helps to manipulate the data while DCL helps to grant and take back authority from a database user.

What is a Hierarchical Database

A hierarchical database is based on the hierarchical model. It stores data in a tree-like structure. Here, data is stored as records which are connected to one another through links. Also, a record is a collection of fields. Each field contains only one value. Moreover, the hierarchy starts from the root data. Then, it expands similar to a tree, adding child nodes to the parent nodes.  A child node will only have a one parent node. However, a parent node can have one or more child nodes.

Main Difference - Relational vs Hierarchical Database

Figure 2: Hierarchical Model

For example, assume a university scenario. It divides data into department and infrastructure data. You can divide Department into course, lecturer and student. A course further divides into theory and practical. Likewise, data is organized into a tree-like structure.

Difference Between Relational and Hierarchical Database

Definition

A relational database is a database based on the relational model of data, as proposed by E. F. Codd in 1970. A hierarchical database is a type of database that organizes the data into a tree-like structure. Hence, this explains the fundamental difference between relational and hierarchical database.

Based Model

That is; Relational database is based on the relational model. In contrast, hierarchical database is based on a hierarchical model.

Method of Storing Data

Also, another difference between relational and hierarchical database is that the relational database stores data in tables while the hierarchical database stores data in a tree-like structure.

Data Retrieval

Data can be retrieved easily using SQL in a relational database. On the other hand, data retrieving is difficult in a hierarchical database.  The whole tree needs to be traversed starting from the root node to retrieve data. Thus, this is an important difference between relational and hierarchical database.

Popularity

Moreover, relational database is more popular and common than hierarchical databases.

Conclusion

In brief, relational and hierarchical databases are two main types of databases. The main difference between relational and hierarchical database is that the relational database follows the relational model and stores data in tables while the hierarchical database follows the hierarchical model and stores data in a tree-like structure. 

Reference:

1. “DBMS Database Models.” Database Models in DBMS | Studytonight, Available here.

Image Courtesy:

1. “Relational model concepts” By User:AutumnSnow – Own work (CC BY-SA 3.0) via Commons Wikimedia
2. “Hierarchical Model” By U.S. Department of Transportationvectorization: Own work – page 10. (Public Domain) via Commons Wikimedia

About the Author: Lithmee

Lithmee holds a Bachelor of Science degree in Computer Systems Engineering and is reading for her Master’s degree in Computer Science. She is passionate about sharing her knowldge in the areas of programming, data science, and computer systems.

Leave a Reply