Hierarchies - Physical Relationships Between Segments

In DL/I, segments are related physically in terms of parent/child hierarchies. These
hierarchical relationships
determine the physical organization of a database. They control how segments are stored in relation to each other. They also define the access paths for getting from one segment to another. In a hierarchical (physical) relationship, the parent segment is referred to as the
physical parent
, and the child segment is referred to as the
physical child
Parent and Child Segments
A parent segment can have zero, one, or more child segments, but a child segment can have only one parent. Each occurrence of a parent segment can have any number of occurrences of a dependent child segment. For example, if employee Bob Jones has two skills, there will be two occurrences of the SKILL child segment for the one occurrence of the EMPLOYEE parent segment.
Parent and Child Occurrences
A child occurrence requires an existing parent occurrence, but a parent occurrence does not require a child occurrence. Two or more child segment occurrences that have the same parent occurrence in a hierarchy are referred to as
physical twins
. Such occurrences are twins only in the sense that they have the same parent occurrence ── not that they contain duplicate data.
Root Segments and Database Records
What is a Root Segment
In a DL/I hierarchical structure, the top-level parent segment is known as the
root segment
. There can be only one root segment in any hierarchy.
What is a Database Record
Collectively, all the parent/child occurrences that depend on a given root segment form a DL/I
database record
. Since there can be only one occurrence of a root segment, the addition of a new root segment occurrence (for example, a new employee) creates a new database record. Database records are variable in size because the number of occurrences for dependent child segments may vary (for example, new skills can be added for a given employee).
A DL/I Physical Database
All of the database records for a particular parent/child hierarchy form a DL/I
physical database
. Since each child segment can have only one parent segment, the resulting structure resembles an inverted tree, with the root segment at the top. The maximum number of segments in a DL/I structure is 255: one root and up to 254 dependent child segments.
Hierarchical Access Path
A DL/I Hierarchy
The basic parent/child structure is hierarchical in that it requires traversing higher levels to reach a specific lower level. In other words, to reach a given child segment occurrence, you must go from the root segment occurrence through all the intermediate parent segment occurrences. This path is known as a
hierarchical access path
. Hierarchical paths require that you traverse a structure in a top-to-bottom, left-to-right manner. There is a maximum of 15 levels (that is, 14 parent segments, including the root) in a DL/I hierarchical path.
The illustrations on the next few pages show different representations of the same DL/I hierarchy.
Physical Parent/Child Relationships
The illustration below illustrates the physical parent/child relationships among the segments. It is these physical relationships that define the hierarchy. The names of the segments are SEGA, SEGB, SEGC, and SEGD.
IDMSDB--Hierarchical Access Path
Figure 6. Physical segment relationships
DBD Source Statements For the Hierarchy
The sample below shows the Database Description (DBD) source statements used to define the hierarchy and the parent/child relationships among the segments.
Figure 7. DBD source statements for sample hierarchy
Hierarchy with Database Records
The illustration below shows a hierarchy with database records
Note that in the A1 record, segment SEGC has three occurrences. In the A2 record, segment SEGD has two occurrences. The hierarchical path to the D2b occurrence is by way of the following occurrences: A2, B2, C2, D2a (from top to bottom and left to right).
IDMSDB--Hierarchical Access Path (2)
Figure 8. Hierarchy with database records