Embedded Structures

Many data relationships can be represented by a hierarchical or tree structure. In the Enterprise Database Server, these relationships can be represented by including a data set among the items of a record. If a data set contains another data set as an item, then the contained data set is called an embedded data set, and the data record in which it is declared is called the owner or master of the embedded structure. Any number of embedded records can belong to each master.

Sets, subsets, and accesses can be embedded within a data set.

A separate physical file is established for each data set. Normally, all of the records for a data set are contained in a single file; however, in embedded data sets, the database administrator can divide or partition the records of a data set in several files. Partitioning is described under “Data Set Physical Options” in this section. Each database file is assigned a unique name by the system. The conventions used to assign file names are described in Tailored File-Naming Conventions.

Example

This example illustrates embedded data sets. In the example, the CITIES data set is embedded in the COUNTIES data set, which in turn is embedded in the STATES data set.

STATES DATA SET
  (
    STATE-NAME        ALPHA(30);
    COUNTIES          DATA SET
      (
        COUNTY-NAME     ALPHA(30);
        CITIES          DATA SET
          (
            CITY-NAME     ALPHA(30);
            CITY-POP      NUMBER(8);
          );
        CITIES-BY-NAME  SET OF CITIES
          KEY IS CITY-NAME;
       );
    COUNTIES-BY-NAME  SET OF COUNTIES
      KEY IS COUNTY-NAME;
  );
STATES-BY-NAME      SET OF STATES
  KEY IS STATE-NAME;