Previous Topic: FIELD StatementNext Topic: Unidirectional Relationship


Logical Relationships Between Segments

What Logical Relationships Do

Logical relationships provide a way of extending the basic hierarchical relationships. They have no effect on how segments are physically stored, but they do let you define multiple access paths to the same physical data. The segments defined in a logical relationship can be on the same hierarchical path or on different hierarchical paths.

Logical Parent and Logical Child

In a logical relationship, the parent segment is referred to as the logical parent, and the child segment is referred to as the logical child.

In a given logical relationship, a child segment can have only one physical parent and only one logical parent. Note that a parent segment can be both physical and logical parent to the same child segment. Also, the same child segment can have more than one logical parent, but in different logical relationships.

If two or more logical child segment occurrences have the same logical parent occurrence, they are referred to as logical twins. As with physical twins, they are twins only in the sense that they have the same parent occurrence.

Hierarchical (physical) relationships always occur within the same database. Logical relationships can occur within the same database or can involve segments from different databases.

DBD Source Statements for Two Databases

The example below shows sample DBD source statements for defining two databases (PHYSDB1 and PHYSDB2). Note that the DBD definitions define both hierarchical and logical relationships.

Each hierarchical relationship involves only segments that are in the same database. A logical relationship, though, can involve segments from its own database definition and segments from another database definition.

 DBD      NAME=PHYSDBD1,ACCESS=HDAM
 DATASET  DD1=HDAM1,DEVICE=3350,BLOCK=2048,SCAN=3
 SEGM     NAME=SEG1,PTR=TWINBWD,RULES=LLV
 FIELD    NAME=(FIELD1,SEQ,U),BYTES=60,START=1
 FIELD    NAME=FIELD2,BYTES=15,START=61
 FIELD    NAME=FIELD3,BYTES=75,START=76
 LCHILD   NAME=(SEG6,PHYSDB2),PAIR=SEG2,PTR=DBLE
 SEGM     NAME=SEG2,PARENT=SEG1,PTR=PAIRED
               SOURCE=(SEG6,DATA,PHYSDB2)
 FIELD    NAME=(FIELD4,SEQ,U),BYTES=21,START=1
 FIELD    NAME=FIELD5,BYTES=20,START=22
 SEGM     NAME=SEG3,BYTES=200,PARENT=SEG1
 FIELD    NAME=(FIELD6,SEQ,U),BYTES=99,START=1
 FIELD    NAME=FIELD7,BYTES=101,START=100
 SEGM     NAME=SEG4,BYTES=100,PARENT=SEG1
 FIELD    NAME=(FIELD8,SEQ,U),BYTES=15,START=1
 FIELD    NAME=FIELD9,BYTES=15,START=51
 DBDGEN
 FINISH
 END


 DBD      NAME=PHYSDBD2,ACCESS=HDAM,
               RMNAME=(DLZHDC20,7,700,250)
 DATASET  DD1=HDAM2,DEVICE=3350,BLOCK=2048,SCAN=3
 SEGM     NAME=SEG5,BYTES=31,PTR=TWINBWD,RULES=(VLV)
 FIELD    NAME=(FIELD9,SEQ,U),BYTES=21,START,TYPE=P
 FIELD    NAME=FIELD10,BYTES=10,START=22
 SEGM     NAME=SEG6,
               PARENT=((SEG5,DBLE),(SEG1,P,PHYSDB1)),
               BYTES=80,PTR=(LPARNT,TWINBWD),RULES=VVV
 FIELD    NAME=(FIELD11,SEQ,U),START=1,BYTES=60
 FIELD    NAME=FIELD12,BYTES=20,START=61
 SEGM     NAME=SEG7,BYTES=20,PTR=T,
               PARENT=(SEG6,SNGL)
 FIELD    NAME=FIELD13,BYTES=9,START=1
 FIELD    NAME=FIELD14,BYTES=11,START=10
 SEGM     NAME=SEG8,BYTES=75,PTR=T,
               PARENT=(SEG6,SNGL)
 FIELD    NAME=FIELD16,BYTES=50,START=1
 FIELD    NAME=FIELD17,BYTES=25,START=51
 DBDGEN
 FINISH
 END

Figure 9. DBD source statements for two databases

Three Types of Logical Relationships

DL/I supports three types of logical relationships: