Specifying logical relationships in the physical DBD

For each of the databases involved in a logical relationship, you must code a physical DBD.

All statements in the physical DBD are coded with the same format used when a logical relationship is not defined, except for the SEGM and LCHILD statements. The SEGM statement, which describes a segment and its length and position in the database hierarchy, is expanded to include the new types of pointers. The LCHILD statement is added to define the logical relationship between the two segment types.

In the SEGM statements of the examples associated with the following figures, only the pointers required with logical relationships are shown. No pointers required for use with HD databases are shown. When actually coding a DBD, you must ask for these pointers in the PTR= parameter. Otherwise, IMS will not generate them once another type of pointer is specified.

The following figure shows the layout of segments.

Figure 1. Layouts of segments used in the examples
begin figure description. This figure is described in the surrounding text. end figure description.

This is the hierarchical structure of the two databases involved in the logical relationship. In this example, we are defining a unidirectional relationship using symbolic pointing. ORDITEM has an LPCK and fixed intersection data, and DELIVERY and SCHEDULE are variable intersection data.

The following figure shows physical DBDs for unidirectional relationships.

Figure 2. Physical DBDs for unidirectional relationship using symbolic pointing
ORDER database: ORDER is root. Below ORDER is ORDITEM. Below ORDITEM are DELIVERY and SCHEDULE. ITEM database: ITEM segment.

The following DBD is for the ORDER database:

***********************************************************************   
* Change the ACCESS/RMNAME parms as needed.                           *  
* Change the DATASET label, DD name, and block size as needed.        *  
*                                                                     *  
***********************************************************************   
        DBD    NAME=ORDDB,ACCESS=(HDAM,OSAM),                          X
               RMNAME=(DFSHDC20,003,003,025)                            
DSG01   DATASET  DD1=DDORDDB,BLOCK=4096                                 
        SEGM   NAME=ORDER,BYTES=50,FREQ=28000,PARENT=0                  
        FIELD  NAME=(ORDKEY,SEQ),BYTES=10,START=1,TYPE=C                
        FIELD  NAME=ORDATE,BYTES=6,START=41,TYPE=C                      
        SEGM   NAME=ORDITEM,BYTES=17,PARENT=((ORDER),(ITEM,P,ITEMDB))   
        FIELD  NAME=(ITEMNO,SEQ),BYTES=8,START=1,TYPE=C                 
        FIELD  NAME=ORDITQTY,BYTES=9,START=9,TYPE=C                     
        SEGM   NAME=DELIVERY,BYTES=50,PARENT=ORDITEM                    
        FIELD  NAME=(DELDAT,SEQ),BYTES=6,START=1,TYPE=C                 
        SEGM   NAME=SCHEDULE,BYTES=50,PARENT=ORDITEM                    
        FIELD  NAME=(SCHEDAT,SEQ),BYTES=6,START=1,TYPE=C                
        DBDGEN                                                          
        FINISH                                                          
        END 

The following DBD is for the ITEM database:

***********************************************************************  
* Change the ACCESS/RMNAME parms as needed.                           *  
* Change the DATASET label, DD name, and block size as needed.        *  
*                                                                     *  
***********************************************************************   
        DBD    NAME=ITEMDB,ACCESS=(HDAM,OSAM),                         X
               RMNAME=(DFSHDC20,003,003,025)                            
DSG01   DATASET  DD1=DDITEM,BLOCK=4096                                  
        SEGM   NAME=ITEM,BYTES=60,FREQ=50000,PARENT=0                   
        FIELD  NAME=(ITEMKEY,SEQ),BYTES=8,START=1,TYPE=C                
        LCHILD NAME=(ORDITEM,ORDDB)                                     
        DBDGEN                                                          
        FINISH                                                          
        END

In the ORDER database, the DBD coding that differs from normal DBD coding is that for the logical child ORDITEM.

In the SEGM statement for ORDITEM:

Procedure

  1. The BYTES= parameter is 17. The length specified is the length of the LPCK, plus the length of the fixed intersection data. The LPCK is the key of the ITEM segment, which is 8 bytes long. The length of the fixed intersection data is 9 bytes.
  2. The PARENT= parameter has two parents specified. Two parents are specified because ORDITEM is a logical child and therefore has both a physical and logical parent. The physical parent is ORDER. The logical parent is ITEM, specified after ORDER. Because ITEM exists in a different physical database from ORDITEM, the name of its physical database, ITEMDB, must be specified. Between the segment name ITEM and the database name ITEMDB is the letter P. The letter P stands for physical. The letter P specifies that the LPCK is to be stored on DASD as part of the logical child segment.

In the FIELD statements for ORDITEM:

  1. ITEMNO is the sequence field of the ORDITEM segment and is 8 bytes long. ITEMNO is the LPCK. The logical parent is ITEM, and if you look at the FIELD statement for ITEM in the ITEM database, you will see ITEM's sequence field is ITEMKEY, which is 8 bytes long. Because ITEM is a root segment, the LPCK is 8 bytes long.
  2. ORDITQTY is the fixed intersection data and is coded normally.

In the ITEM database, the DBD coding that differs from normal DBD coding is that an LCHILD statement has been added. This statement names the logical child ORDITEM. Because the ORDITEM segment exists in a different physical database from ITEM, the name of its physical database, ORDDB, must be specified.