Accessing a segment through different paths

Sometimes an application program needs to process the data in a different order than the way it is arranged in the hierarchy.

For example, an application program that processes data in a purchasing database also requires access to a segment in a patient database:

The following figure shows the hierarchies that Program A and Program B require for their processing. Their processing requirements conflict: they both need to have access to the information that is contained in the TREATMNT segment in the patient database. This information is:

To Program B this is not information about a patient's treatment; it is information about the disbursement of a medication. To the purchasing database, this is the disbursement segment (DISBURSE).

The following figure shows the hierarchies for Program A and Program B. Program A needs the PATIENT segment, the ILLNESS segment, and the TREATMNT segment. Program B needs the ITEM segment, the VENDOR segment, the SHIPMENT segment, and the DISBURSE segment. The TREATMNT segment and the DISBURSE segment contain the same information.

Figure 1. Patient and inventory hierarchies
Begin figure description. On the left, hierarchical structure of PATIENT, ILLNESS, TREATMNT. On the right, hierarchical structure of ITEM, VENDOR, SHIPMENT, DISBURSE. End figure description.

Instead of storing this information in both hierarchies, you can use a logical relationship. A logical relationship solves the problem by storing a pointer from where the segment is needed in one hierarchy to where the segment exists in the other hierarchy. In this case, you can have a pointer in the DISBURSE segment to the TREATMNT segment in the medical database. When IMS receives a request for information in a DISBURSE segment in the purchasing database, IMS goes to the TREATMNT segment in the medical database that is pointed to by the DISBURSE segment. The following figure shows the physical hierarchy that Program A would process and the logical hierarchy that Program B would process. DISBURSE is a pointer segment to the TREATMNT segment in Program A's hierarchy.

Figure 2. Logical relationships example
Begin figure description. On left, hierarchical structure of Patient, Illness, Treatmnt. On right, hierarchical structure of Item, Vendor, Shipment, Disburse. Pointer from Disburse to Treatmnt. End figure description.

To define a logical relationship between segments in different hierarchies, you use a logical DBD. A logical DBD defines a hierarchy that does not exist in storage, but can be processed as though it does. Program B would use the logical structure shown in the previous figure as though it were a physical structure.