Hierarchical database model

In this Article we will learn about Hierarchical database model with real example and SQL query.

You can always download the source code here.

dicon Db-Script

First we know,

What is Hierarchical database model:

Hierarchical database model is organized data in database like tree. The data  is stored as record  which are connected one another thought links. The structure is based on the rule one parent can have many children but children is not allow many parent. Single children can have one parent .

Bellow is the Example of a hierarchical model

hi

 

We see above picture CEO have three children COO,CTO and CIO. COO and CIO have not any children. CTO have tow children . We will approve this in our query, After few time. For this region we will use tow table one is named “tbl_Designation” and other is named “tbl_Employee”. Those table have gived bellow.

First Once :

5657567567

 

 

 

 

 

 

Fig: tbl_Designation.

Another Once :

555555555

 

 

 

 

 

 

Fig: tbl_Employee

We will do this simple query. this query is nothing just selfjoin in table Bellow is the following query.

After execute above query.we can see bellow result.

111111111111111

 

 

 

 

Fig: Query result.

We have done everything! That’s fantastic, right? Happy coding.

 

Leave a Reply

Your email address will not be published. Required fields are marked *