A hierarchical database is a database that organizes records as a tree of parent and child segments, in which every child record belongs to exactly one parent and data is retrieved by navigating from the root down predefined paths. Among the classic database models in Databases, it is the oldest widely deployed design, best known through IBM Information Management System (IMS), which was built in the 1960s for the Apollo program and still runs high-volume transaction workloads in banking, insurance and airlines.
The model trades flexibility for speed: when queries follow the tree, access is direct and extremely fast, but relationships that do not fit a strict one-to-many structure are awkward to represent. Understanding it explains why the relational model was invented and why tree-shaped data reappears today in document stores, XML and JSON.
How a hierarchical database organizes records
A hierarchical database stores data as segments (record types) linked by parent-child relationships that form an inverted tree. The top segment is the root segment; each occurrence of the root, together with all its dependent segments, is called a database record. A customer root, for example, can own account segments, and each account can own transaction segments.
Programs read data through navigational access: they position on a root, then move down to children or across to siblings in a fixed hierarchical sequence, usually a preorder traversal from top to bottom and left to right. In IMS, this navigation uses DL/I calls such as GU (get unique), GN (get next) and GNP (get next within parent), and the structure is declared in a database description (DBD), while each program sees a filtered view defined by a program specification block (PSB).
The following table lists the core building blocks of the model and their role in the tree.
| Element | Meaning | Example |
|---|---|---|
| Root segment | Top record type with no parent | Customer |
| Child segment | Record type owned by one parent type | Account under customer |
| Twin segments | Occurrences of one type under the same parent | Several accounts of one customer |
| Sibling segments | Different types under the same parent | Accounts and addresses of a customer |
| Hierarchical path | Chain of segments from root to a target | Customer, account, transaction |
Physical storage and access methods
The physical layout of a hierarchical database is designed around the tree, which is why reads along the hierarchy are so efficient. Children are typically stored physically close to their parent or connected by pointers, so retrieving a complete database record often needs only a few block reads and no join processing.
IMS offers several access methods, each balancing sequential throughput, direct lookup speed and space reuse. Choosing among them is a core design decision, summarized in the table below.
| Access method | Organization | Typical strength |
|---|---|---|
| HSAM | Sequential, no index | Batch reading of whole files |
| HISAM | Indexed root, sequential dependents | Keyed root access with modest updates |
| HDAM | Hashed root via randomizer, pointer-linked dependents | Fast direct access by key |
| HIDAM | Indexed root, pointer-linked dependents | Both direct and sequential root access |
| DEDB (Fast Path) | Partitioned areas for high volume | Very high transaction rates |
Because pointers and placement encode the structure, the schema is tightly bound to the storage layout. Adding a new segment type or reordering segments usually requires a database reorganization and changes to the DBD, which is a major operational cost compared with altering a relational table.
Hierarchical database compared with other models
The hierarchical model differs from its successors mainly in how it expresses relationships and how programs ask for data. The network model (CODASYL) generalized the tree by allowing a record to have several owners, while the relational model removed physical paths entirely and replaced them with declarative queries over tables.
The comparison below places the hierarchical approach next to its closest relatives in the family of database models.
| Model | Relationship structure | Query style | Schema flexibility |
|---|---|---|---|
| Hierarchical database | Strict one-to-many tree | Navigational, record at a time | Low |
| Network database | Many-to-many via owner-member sets | Navigational, record at a time | Low to moderate |
| Relational database | Tables linked by keys | Declarative SQL, set at a time | Moderate to high |
| Document database | Nested documents, references | Document queries and APIs | High |
| Graph database | Arbitrary nodes and edges | Pattern-matching traversal | High |
A document database is often described as a modern descendant of the hierarchical idea, since a JSON document is itself a small tree. The key difference is that document stores keep each tree as a self-contained unit with flexible fields, whereas a hierarchical database enforces a fixed, centrally defined schema.
Strengths and suitable workloads
A hierarchical database excels when the data is naturally tree-shaped and the dominant access paths are known in advance. In those conditions it delivers predictable, very low latency and high throughput, which is why mainframe installations still process billions of IMS transactions per day.
- Bill of materials structures, where an assembly contains subassemblies and parts.
- Account hierarchies in banking, with customer, account and posting levels.
- Organizational charts and reporting lines with one manager per employee.
- Directory and registry structures, such as LDAP directories and the Windows Registry, which follow the same tree principle.
The model also provides strong referential integrity by design: a child cannot exist without its parent, and deleting a parent removes all its dependents automatically.
Limitations and common design problems
The main weakness of the hierarchical database is its inability to express many-to-many relationships natively. A student who attends several courses, where each course has many students, cannot sit under a single parent without duplicating data, and duplication leads to update anomalies.
IMS mitigates this with logical relationships and secondary indexes, but these add complexity and tie applications even more closely to the physical design. The table below lists typical problems and how practitioners address them.
| Problem | Cause | Usual response |
|---|---|---|
| Redundant data | Many-to-many data forced into one tree | Logical relationships or a second hierarchy |
| Slow ad hoc queries | Search does not follow the defined path | Secondary indexes or extract to SQL |
| Costly schema change | Structure bound to storage layout | Planned reorganization windows |
| Program dependence | Code embeds navigation logic | Encapsulate access in service layers |
| Skills shortage | Few engineers trained in DL/I | Modernization or SQL access layers |
A frequent misconception is that hierarchical systems are obsolete. In reality, IMS remains in active production, now with SQL and Java interfaces, and many organizations keep it because a migration would carry high risk and cost for little performance gain.
The idea in brief
A hierarchical database stores information like a family tree or a set of folders on a computer. Each item sits under exactly one parent item, and to find something you start at the top and walk down the branches.
This makes it very fast when you already know the route, such as going from a customer to their accounts and then to the payments on one account. It becomes clumsy when one item belongs to several parents, because the tree has no natural place for such links.
A practical scenario
A large retail bank runs its core deposit system on a mainframe hierarchical database. The root segment is the customer, with account segments beneath it and posting segments under each account. A teller application issues a get unique call for the customer key, then reads the accounts and the most recent postings within that parent, retrieving everything in a handful of block reads.
During the month-end peak, the system handles thousands of balance inquiries per second with response times of a few milliseconds. When the marketing team asks for an analysis of all customers who hold both a mortgage and a savings account in a given region, the bank does not run it against the tree. Instead, a nightly job replicates the data to a relational warehouse, where SQL joins answer such cross-cutting questions. The result is a stable division of labor: the hierarchical database serves high-volume, path-based transactions, and the relational copy serves flexible analysis.