Logical relationship is a path between segments that otherwise would be unrelated. A logical relationship is always between two segments. Although those segments are usually in separate physical databases, that does not have to be the case; a logical relationship can also connect two segments within the same physical database.
Consider the two independent databases (Customer and Inventory) the structures are as shown above. In the Customer database, assume, a particular receivable segment might have several subordinate line item segments, each for different product. Notice that the key of LINE ITEM segment consists of 3 byte Vendour code and 5 byte Item number.
In the Inventory DB there are three segments Viz., Vendor segment, Item Segment, Stock Location segments. Each Vendor will have lot of items in turn each item can be placed at different stock locations. Relevent portions of the two DBDs are shown below for reference.
SEGM NAME=LINEITEM,PARENT=RECVABLE,BYTES=16 FIELD NAME=(ITKEYVEN,SEQ,U),BYTES=3,START=1,TYPE=C FIELD NAME=ITKEYNUM,BYTES=5,START=4,TYPE=C FIELD NAME=LIUNTPRC,BYTES=4,START=9,TYPE=P FIELD NAME=LIQUANTY,BYTES=4,START=13,TYPE=P
SEGM NAME=INITMSEG,PARENT=INVENSEG,BYTES=48 FIELD NAME=(INITMNUM,SEQ),BYTES=5,START=1,TYPE=C FIELD NAME=INITMDES,BYTES=35,START=6,TYPE=C FIELD NAME=INITMPRC,BYTES=4,START=41,TYPE=P FIELD NAME=INITMCST,BYTES=4,START=45,TYPE=P
The item number of Line Item segment (CUSTOMER) and Item number of Item segment (INVENTORY) are same. Access to Stock Locations segment can be provided by adding this segment (Stock Location Segment - INVENTORY) to the hierarchical structure of the CUSTOMER database, performing a new DBDGEN and reloading the database including the new stock location segment occurrences. The new database would then contain the stock location information, which is as shown below.
As per the database structure above, the Stock Location information is already existing in Inventory Database. So it would be redundent to store it again in CUSTOMER database. One way to gain access to both the databases is to code a PSB that contains two PCBs, one for each physical database. In such case application programs could provide the program logic to tie together the two databases.
The other approach is to use the logical relation ship concept. This provides a method for hooking two or more databases together in such a way that application programs can work with them as if they are of single logical data structure.
A Logical database is an ordered set of logical database record occurrences. Like a physical database record, a logical database record is a hierarchical arrangement of fixed-length segments. Like a physical database, a Logical database is defined by means of a DBD. However a logical database differs from a physical database in that it has no existence in its own right; instead it is defined in terms of one or more existing physical databases.
Specifically each logical database record occurrence consists of segments from several distinct physical database record occurrences. Thus logical database imposes a hierarchical structure on the data that is different from the hierarchical structure represented by the underlaying physical databases; in other words it provides the user with an alternative view of the data. In IMS the logical database is really part of the conceptual level rather than the external level. Logical database will ideally look exactly like a physical database to the user, atleast as far as retrieval is concerned.
There are three ways in which a logical relationship can be established or implemented. These methods of implementation are as follows:
Unidirectional Logical Relationship
Bidirectional physically paired Logical Relationship
Bidirectional virtually paired Logical Relationship
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on IBMMainframer Community!