How secondary indexes restructure the hierarchy of DEDB databases

When a primary DEDB database is accessed through its secondary index using the PCB with the PROCSEQD= parameter, the primary DEDB database is processed in an alternate sequence.

When the PROCSEQD= parameter in the PCB is coded, the way in which the application program perceives the database record changes. If the target segment is a root segment in the primary DEDB database, the inverted structure in the primary DEDB database that is using the secondary index is the same as the physical structure of the primary DEDB database. Subsequent unqualified DL/I GNP or GN calls after the GU of the target segment return segments in the primary DEDB database in the physical structure order.

If the target segment is not a root segment in the primary DEDB database, the hierarchy in the database record is conceptually restructured as an inverted structure. The DEDB inverted structure access is limited to a subset of segments. For DEDB inverted structure access, the target segment, its direct parent segments from the target segment to the root segment, and all its child segments from the target segments are accessible.

For a target segment that is not a root segment, the direct parent segments from the target segment to the root segment must have a unique key FIELD statement defined for each direct parent segment and the target segment. If there is no unique key in a FIELD statement for a direct parent segment, the DBDGEN utility terminates with an MNOTE 8 and message DGEN332.

Subsequent unqualified DL/I GNP or GN calls after the GU of the target segment return segments in the primary DEDB database in the conceptually reconstructed DEDB inverted structure order:

  1. Transverse vertically up from the target segment through its direct parent segments to the root segment.
  2. The target's direct parent segments to the root segment are returned.
  3. Transverse vertically down from the target segment to all its child segments.
  4. One or more of the target's child segments are returned if requested; specify SENSEG statements for the target's child segments.

The following two figures illustrate how the inverted structure is conceptually restructured when the PROCSEQD= parameter is coded in the PCB to indicate alternate sequence processing using the secondary index database for a primary DEDB database.

The following figure illustrates a physical structure of a database record with root A and target segment of G.

Figure 1. Physical database structure with target segment of G
Alt text for when graphic is ready: begin figure description. Root: A. A's children: B, D. B's child: C. D's children: E, G (target), K. E's child: F. G's children: H, J. H's child: I. end figure description

The following figure illustrates a DEDB inverted database structure with a target segment of G.

Figure 2. DEDB inverted database structure from target segment of G
Alt text for when graphic is ready: begin figure description. This figure is described in the surrounding text. end figure description.

The target segment (as shown in the figures) is segment G. Target segment G becomes the root segment in the restructured hierarchy. All dependents of the target segment (segments H, I, J) remain dependents of the target segment. However, all segments on which the target is a direct dependent (segments D and A) are put in the leftmost positions of the restructured hierarchy. Their position in the restructured hierarchy is the order of immediate dependency. D becomes an immediate dependent of G, and A becomes an immediate dependent of D.

The new inverted structure is called a DEDB secondary data structure. A processing restriction exists when using a secondary data structure, and the target segment and the segments on which it was dependent (its physical parents, segments D and A) cannot be inserted or deleted.

The following steps describe the DL/I call sequence using the PCB with the PROCSEQD= parameter:

  1. A qualified GU call returns target segment G.
  2. A subsequent unqualified GNP or GN calls return segments D, A, H, I, J.
  3. For unqualified GNP calls, a GE status code is returned after segment J.
  4. For unqualified GN calls, a GN call returns the next nth segment after segment G in the secondary index database.
  5. For unqualified GN calls, repeat steps 2 and 4. A GB status code is returned when there are no more segments in the secondary index database.