Scope Rules for Manual Subsets

The scope rules for manual subsets, like the scope rules for links, control which data set can be referenced. An automatic subset must be declared at the same level as the data set it references; that is, the subset and data set must both be disjoint, or they must be items of the same data set.

A manual subset must refer to a data set that is either disjoint or owned by an ancestor of the subset. (An ancestor is the owner, the owner's owner, and so on).

Example 1

The following DASDL description uses a manual subset:

A DATA SET
 (
  B DATA SET
   (
    D DATA SET( ... );
    E DATA SET( ... );
   );
  C DATA SET
   (
    F DATA SET( ... );
    G DATA SET( ... );
   );
 );
X DATA SET
 (
  Y DATA SET( ... );
  Z DATA SET( ... );
           );

Figure 11–1 illustrates a manual subset based on the previous DASDL description.

Figure 13. Manual Subset

Manual Subset


A disjoint manual subset can reference data sets A or X. An embedded manual subset declared in data set A can reference data sets A, B, C, or X. An embedded manual subset declared in data set B can reference data sets A, B, C, D, E, or X.

The database administrator is responsible for declaring the manual subset and selecting the data set that it references, but host language programs are responsible for maintaining the subset.

Host language programs must observe the following restrictions when inserting entries in a manual subset:

  • Manual subsets must refer to records contained in the data set specified when the subset was declared.

  • If the subset refers to a disjoint data set, then the subset can refer to any record in the data set. If the subset refers to an embedded data set, the record being inserted must be owned by an ancestor of the record containing the subset. (An ancestor is the owner, the owner's owner, and so on.)

Example 2

The following DASDL description uses the scope rules for the manual subsets:

A DATA SET
 (
  B DATA SET ( ... );
  C DATA SET
   (
    D DATA SET ( ... );
    S SUBSET ... ;
   );
 );

Figure 11–2 illustrates the scope rules for the manual subsets declared in the previous DASDL.

Figure 14. Scope Rules for Manual Subsets

Scope Rules for Manual Subsets


Figure 11–2 depicts a portion of the database with record A4 as the current record of data set A and record C17 as the current record of data set C. The embedded subset S owned by record C17 can reference only some data set records.

The record relationship for these subsets is based on the following conditions:

  • If the subset references data set A, it can reference any record in data set A.

  • If the subset references data set B, it can reference records B54, B55, B58, and B60.

  • If the subset references data set C, it can reference records C15 and C17.

  • If the subset references data set D, it can reference records D34, D37, and D39.