Physical child first and last pointers

With physical child first and last pointers (PCF and PCL), each parent segment in a database record points to both the first and last occurrence of its immediately dependent child segment types.

PCF and PCL pointers must be used together, since you cannot use PCL pointers alone. The following figure shows PCF and PCL pointers:

Figure 1. Physical child first and last pointers
PCF pointers from COURSE to INSTR, first LOC, and first STUDENT, and from INSTR to EDUC and EXPR. PCL pointers from COURSE to INSTR, second LOC, and third STUDENT, and from INSTR to EDUC and EXPR.

Note that if only one physical child of a particular parent segment exists, the PCF and PCL pointers both point to the same segment. As with PCF pointers, PCF and PCL pointers leave the hierarchy only partly connected, and no pointers exist to connect occurrences of the same segment type under a parent. Physical twin pointers can be used to form this connection.

PCF and PCL pointers (as opposed to just PCF pointers) are typically used when:

On insert operations, if the ISRT rule of LAST has been specified, segments are inserted at the end of all existing segment occurrences for that segment type. When PCL pointers are used, fast access to the place where the segment will be inserted is possible. This is because there is no need to search forward through all segment occurrences stored before the last occurrence. PCL pointers also give application programs fast retrieval of the last segment in a chain of segment occurrences. Application programs can issue calls to retrieve the last segment by using an unqualified SSA with the command code L. When a PCL pointer is followed to get the last segment occurrence, any further movement in the database is forward.

A PCL pointer does not enable you to search from the last to the first occurrence of a series of dependent child segment occurrences.

Four bytes are needed in each parent segment for each PCF and PCL pointer.

PCF and PCL pointers are specified by coding the PARENT= operand in the SEGM statement in the DBD as PARENT=((name,DBLE)). This is the SEGM statement for the child being pointed to, not the SEGM statement for the parent. Note, however, that the pointers are stored in the parent segment.

If you are using DDL, PCF and PCL pointers are specified by coding the FOREIGN KEY clause in the CREATE TABLE statement for the database as FOREIGN KEY REFERENCES table_name DOUBLE. This is the table for the child being pointed to, not the table for the parent.

A parent segment can have SNGL specified on one immediately dependent child segment type and DBLE specified on another.

The following example DBD statement specifies PCF and PCL pointers.

 DBD
 SEGM A
 SEGM B  PARENT=((name.SNGL))   (specifies PCF pointer only)
 SEGM C  PARENT=((name.DBLE))   (specifies PCF and PCL pointers)

The following example shows the same PCF and PCL pointer specifications as specified by using DDL.

CREATE DATABASE ...
CREATE TABLE A ...
CREATE TABLE B (
       ...
       FOREIGN KEY REFERENCES table_name SINGLE    (specifies PCF pointer only)
     )
CREATE TABLE C (
       ...
       FOREIGN KEY REFERENCES table_name DOUBLE    (specifies PCF and PCL pointers)
     )

The following figure shows the result of specifying PCF and PCL pointers in a database definition.

Figure 2. Specifying PCF and PCL pointers
Segment A (root) points to first B segment (PCF), first C segment (PCF), and last C segment (PCL).