Tutorial The Hierarchal Model

Swati Mishra

Content Writer
A collection of records which are connected with each other in the form of tree, this is Hierarchical model. Each record is collection of attributes. A link is association between two records. In many data organization tree structures occur automatically. Now we will take the example of collage. A college has number of programmes. Each program has number of courses. And the number of students registered for these courses. These four Entity College, program, course, and student make the different level of hierarchical structure.

Features of hierarchical data model

These are the various features are in the hierarchical data model which are described below.
  • In the hierarchical model, hierarchical tree can have one root record type and this record type does not have a parent record type.
  • It is possible to root can have any number of child record type and child record type can itself be a root of a hierarchical subtree.
  • Each child record type can have only one parent record type, So It can not possible M: N relationship be directly expressed between two record types.
  • Data in parent record applies to all its children records.
  • It is necessary that a child record occurrence must have a parent record occurrence, when we deleting the parent record type then it is necessary to deleting all its children record occurrence.
Replication Vs Virtual record

The hierarchical model does not support many to many relationships directly. In the hierarchical model, by using this following method Replication or Virtual record many to many relationships can be expressed.
Replication of the data meaning is a waste of storage space. The other method of representing the many to many relationships in the hierarchical data model is to use an indirect scheme.
In the hierarchical model the solution is to use the Virtual record. A virtual record is essentially a record containing a pointer to an occurrence of an actual physical record type. This physical record type also called logical parent and the virtual record is the logical child. When in the database trees replication process occur, we keep single copy of that record in one of the trees and according to need we can replace it. Each other record with the virtual containing pointer to that physical record. Now we assume the record which is let R is the record type that is replicated in several hierarchical pictures say H1, H2 ….Hn. We have to eliminate this replication we create a new virtual record type virtual R and the replace R in the each of the n-1 trees with a record of type virtual R. whereas virtual R will not contain any data.

How to access data in Hierarchical structure

It shows the relationship among parents, children, cousins, uncles, aunts and siblings. A tree is collection of nodes, each nodes connected to each other with the relations.
If we talk about an ordered tree then it is also a tree in which order are relative of subtrees. This relative order provides the ordering from left to right ordering and also signifies the vertical placement or the level of subtrees. Traversing an ordered tree can be in different ways. We can the order of processing of subtrees it may be left to right or it may be from right to left.
We will take the preorder processing of ordered tree which will process the node in the sequence
A, B, E, F, C, G, D, H, I, J
  • One node is represented as the root node and the remaining node are called sub trees.
  • The ordering is starts from left to right.
  • Node A is represent as Root node and the nodes B, C, D as its children nodes. And the B, C, D is the turn into root nodes with its children nodes E, F, G, and the H, I, J.
  • The order of processing the sub trees (left to right or right to left). This is called pre-order traversal.
  • This process used two types of pointers, first is Child and the other is the Sibling pointers.
  • The child pointer is used to point to the leftmost child and the sibling pointer is used to right siblings. The siblings have same parent.

By using this process we will obtain the Tree representation. Which is the binary tree obtained by the all siblings of a node connecting together and the deleting all links from a node to its children except for the link to its left most children.

How to implement the hierarchical data model

Everything which is occurrence of hierarchical tree can be stored as the variable length that is the physical record, the hierarchy of the nodes are being stored in the preorder. When in the addition of the stored record contains a prefix field. This prefix field contains the control information including the pointers, flags, locks, and the counters, which are used by the database management system to usage and enforce data integrity.
A number of methods which may store in the physical medium the hierarchical trees, it affects the performance of the system and also the operations which are performed on the database. If we take the example for this, if each occurrence of the hierarchical tree is stored as the variable length record in the magnetic tape like device, the database management system will allow to the user for sequential retrieval of data and the insertion of the data or it is the modification of data may be disallow or perform only by the re recreating the whole database with the insertion of data and the modification storage of the hierarchical database on the directly access device allows an index structure to be supported for the root nodes and also allows the occurrence of the hierarchical tree.

By using pointers of the preorder hierarchical type or the child type or the sibling type represent the hierarchy. Pointer is the hierarchical type, each record has the pointer which indicate that points to next record in the preorder sequence. Each record has the two types of pointers in the child scheme or sibling scheme. The child pointer indicates the left most child record and the sibling pointers indicate the right sibling or it’s also called the twin. A records has one sibling pointers and the and the number of child pointers.

Manish Mishra

Content Writer
The hierarchy model appears to be a perfect when it comes to dealing with the tables within the database. The hierarchy either goes up to down or down to the up depending on the sequence of execution for that particular required database.