The hierarchical database model is most appropriate for use cases in which the main focus of information gathering is based on a concrete hierarchy, such as several individual employees reporting to a single department at a company.
The schema for hierarchical databases is defined by its tree-like organization, in which there is typically a root “parent” directory of data stored as records that links to various other subdirectory branches, and each subdirectory branch, or child record, may link to various other subdirectory branches.
A tree-structure diagram is the schema for a hierarchical database. Such a diagram consists of two basic components:
- Boxes, which correspond to record types
- Lines, which correspond to links
Hierarchical databases are some of the oldest and simplest kinds of database. They arrange data in a "tree" structure, which is similar to folders and files on a computer. Just as a file on a computer sits in one folder, every record in the database has one "parent." Hierarchically arranged data is often described as having only parent/child relationships. Hierarchical Database Model defines hierarchically- arranged data. Perhaps the most intuitive way to visualize this type of relationship is by visualizing an upside down tree of data. In this tree, a single table acts as the "root" of the database from which other tables "branch" out.
You will be instantly familiar with this relationship because that is how all windows-based directory management systems (like Windows Explorer) work these days. Relationships in such a system are thought of in terms of children and parents such that a child may only have one parent but a parent can have multiple children. Parents and children are tied together by links called "pointers" (perhaps physical addresses inside the file system). A parent will have a list of pointers to each of their children.
This child/parent rule assures that data is systematically accessible. To get to a low-level table, you start at the root and work your way down through the tree until you reach your target. Of course, as you might imagine, one problem with this system is that the user must know how the tree is structured in order to find anything! If a change in the data is necessary, the change might only need to be processed once.
A tree-structure diagram serves the same purpose as an entity–relationship (E-R) diagram; namely, it specifies the overall logical structure of the database. A tree structure diagram is similar to a data-structure diagram in the network model. The main difference is that, in the latter, record types are organized in the form of an arbitrary graph, whereas in the former, record types are organized in the form of a rooted tree
The hierarchical database structure dictates that, while a parent record can have several child records, each child record can only have one parent record. Data within records is stored in the form of fields, and each field can only contain one value. Retrieving hierarchical data from a hierarchical database architecture requires traversing the entire tree, starting at the root node
The First Database Model
- The structure allows representing information using parent/child relationships: each parent can have many children, but each child has only one parent (also known as a 1-to-many relationship).
- This model is recognized as the first database model created by IBM in the 1960s.
- Currently the most widely used hierarchical databases are IMS developed by IBM and Windows Registry by Microsoft.
A Hierarchical database model was widely used during the Mainframe Computers Era. Today, it is used mainly for storing file systems and geographic information. It is used in applications where high performance is required such as telecommunications and banking. A hierarchical database is also used for Windows Registry in the Microsoft Windows operating system. It is useful where the following two conditions are met:
- The data should be in a hierarchical pattern i.e. parent-child relationship must be present.
- The data in a hierarchical pattern must be accessed through a single path only.
Problem with Hierarchical Model
However, as you can imagine, the hierarchical database model has some serious problems. For one, you cannot add a record to a child table until it has already been incorporated into the parent table. This might be troublesome if, for example, you wanted to add a student to who had not yet signed up for any courses. Worse, yet, the hierarchical database model still creates repetition of data within the database. You might imagine that in the database system shown above, there may be a higher level that includes multiple course. In this case, there could be redundancy because students would be enrolled in several courses and thus each "course tree" would have redundant student information.
Redundancy would occur because hierarchical databases handle one-to-many relationships well but do not handle many-to-many relationships well. This is because a child may only have one parent. However, in many cases you will want to have the child be related to more than one parent. For instance, the relationship between student and class is a "many-to-many". Not only can a student take many subjects but a subject may also be taken by many students. How would you model this relationship simply and efficiently using a hierarchical database? The answer is that you wouldn't.
Though this problem can be solved with multiple databases creating logical links between children, the fix is very kludgy and awkward. Faced with these serious problems, the computer brains of the world got together and came up with the network model.
Some features are pointed out below:
- Many to many relationships: It only supports one – to – many relationships. Many to many relationships are not supported.
- Problem in Deletion: If a parent is deleted then the child automatically gets deleted.
- Hierarchy of data: Data is represented in a hierarchical tree-like structure.
- Parent-child relationship: Each child can have only one parent but a parent can have more than one children.
- Pointer: Pointers are used for linking records that tell which is a parent and which child record is.
- Disk input and output is minimized: Parent and child records are placed or stored close to each other on the storage device which minimizes the hard disk input and output.
- Fast navigation: As parent and child are stored close to each other so access time is reduced and navigation becomes faster.
- Predefined relationship: All relations between root, parent and child nodes are predefined in the database schema.
- Re-organization difficulty: Hierarchy prevents the re-organization of data.
- Redundancy: One to many relationships increases redundancy in the data which leads to the retrieval of inaccurate data.
Advantages of hierarchical model
The key advantage of a hierarchical database is its ease of use. The one-to-many organization of data makes traversing the database simple and fast, which is ideal for use cases such as website drop-down menus or computer folders in systems like Microsoft Windows OS. Due to the separation of the tables from physical storage structures, information can easily be added or deleted without affecting the entirety of the database. And most major programming languages offer functionality for reading tree structure databases.
- Promotes data sharing
- Parent/child relationship promotes
- conceptual simplicity and data integrity
- Database security is provided and enforced by DBMS
- Efficient with 1:M relationships
- the hierarchical database model is a very efficient one when the database contains a large number of 1:n relationships and when the users require large number of transactions, using data whose relationships are fixed.
- Hierarchical database was the first database model that offered the data security that is provided and enforced by DBMS.
Disadvantages of hierarchical model
The major disadvantage of hierarchical databases is their inflexible nature. The one-to-many structure is not ideal for complex structures as it cannot describe relationships in which each child node has multiple parents nodes. Also the tree-like organization of data requires top-to-bottom sequential searching, which is time consuming, and requires repetitive storage of data in multiple different entities, which can be redundant.
- Requires knowledge of physical data storage characteristics
- Navigational system requires
- knowledge of hierarchical path
- Changes in structure require changes in all application programs
- Implementation limitations
- No data definition
- Lack of standards
- Although the hierarchical database model is conceptually simple and easy to design, it is quite complex to implement.
- if you make any changes in the database structure of hierarchical database, then you need to make the necessary changes in all the application programs that access the database. thus, maintaining the database and the applications can become very difficult.