Previous Topic: Two-level HierarchiesNext Topic: Multiple Ownership


Multilevel Hierarchies

A member of a set can be the owner of another set, representing a multilevel hierarchy. At Commonweather, for example, dental claims constitute a separate record type called DENTAL-CLAIM. Dental claims are associated with the insurance coverage under which they are made through the COVERAGE-CLAIMS set. The owner of this set, an occurrence of the COVERAGE record type, represents the terms of coverage that an employee has under one of the company's insurance plans. The owning coverage record is a member of the EMP-COVERAGE set, resulting in the three-level hierarchy shown in the figure below. It further illustrates an occurrence of the EMP-COVERAGE set and two related occurrences of the COVERAGE-CLAIMS set.

Multilevel hierarchies

Using several sets to form a multilevel hierarchy is similar to using nested repeating groups in a COBOL record description. The hierarchy shown above, for example, could be represented in the COBOL DATA DIVISION as follows:

01 EMPLOYEE.
   02 EMP-ID                      PIC 9(4).
   02 EMP-NAME.
      03 EMP-FIRST-NAME           PIC X(10).
      03 EMP-LAST-NAME            PIC X(15).
   02 COV-CNT                     PIC S9(4) COMP SYNC.
   02 COVERAGE             OCCURS 0 TO 10 TIMES
                                  DEPENDING ON COV-CNT.
      03 INS-PLAN-CODE            PIC X(3).
      03 SELECTION-DATE           PIC 9(8).
      03 CLAIM             OCCURS 0 TO 10 TIMES
                                  DEPENDING ON CLAIM-CNT.
         04 CLAIM-DATE            PIC 9(8).