Checklist of rules for defining logical databases

Logical relationships can become very complex. To help you to you properly define databases that use logical relationships, you must understand and follow the rules that govern logical relationships.

Before the rules for defining logical databases can be described, you need to know the following definitions:

  • Crossing a logical relationship
  • The first and additional logical relationships crossed

Also, a logical DBD is needed only when an application program needs access to a concatenated segment or needs to cross a logical relationship.

Definition of crossing a logical relationship

A logical relationship is considered crossed when it is used in a logical database to access a segment that is:

  • A physical parent of a destination parent in the destination parent's database
  • A physical dependent of a destination parent in the destination parent's physical database

If a logical relationship is used in a logical database to access a destination parent only, the logical relationship is not considered crossed.

In the following figure, DBD1 and DBD2 are two physical databases with a logical relationship defined between them. DBD3 through DBD6 are four logical databases that can be defined from the logical relationship between DBD1 and DBD2. With DBD3, no logical relationship is crossed, because no physical parent or physical dependent of a destination parent is included in DBD3. With DBD4 through DBD6, a logical relationship is crossed in each case, because each contains a physical parent or physical dependent of the destination parent.

Figure 1. Definition of crossing a logical relationship
begin figure description. This figure is described in the surrounding text. end figure description.

Definition of first and additional logical relationships crossed

More than one logical relationship can be crossed in a hierarchical path in a logical database. The following figure shows three physical databases (DBD1, DBD2 and DBD3) in which logical relationships have been defined. Also in the figure are two (of many) logical databases (DBD4 and DBD5) that can be defined from the logical relationships in the physical databases. In DBD4, the two concatenated segments BF and DI allow access to all segments in the hierarchical paths of their destination parents. If either logical relationship or both is crossed, each is considered the first logical relationship crossed. This is because each concatenated segment type is reached by following the physical hierarchy of segment types in DBD1.

Figure 2. The first logical relationship crossed in a hierarchical path of a logical database
begin figure description. This figure is described in the surrounding text. end figure description.

In DBD5 in the preceding figure, an additional concatenated segment type GI, is defined that was not included in DBD4. GI allows access to segments in the hierarchical path of the destination parent if crossed. When the logical relationship made possible by concatenated segment GI is crossed, this is an additional logical relationship crossed. This is because, from the root of the logical database, the logical relationship made possible by concatenated segment type BF must be crossed to allow access to concatenated segment GI.

When the first logical relationship is crossed in a hierarchical path of a logical database, access to all segments in the hierarchical path of the destination parent is made possible as follows:

  • Parent segments of the destination parent are included in the logical database as dependents of the destination parent in reverse order, as shown in the following figure.
  • Dependent segments of the destination parent are included in the logical database as dependents of the destination parent without their order changed, as shown in the following figure.

When an additional logical relationship is crossed in a logical database, access to all segments in the hierarchical path of the destination parent is made possible, just as in the first crossing.

Figure 3. Logical database hierarchy enabled by crossing the first logical relationship
begin figure description. This figure is described in the surrounding text. end figure description.

Rules for defining logical databases

  • The root segment in a logical database must be the root segment in a physical database.
  • A logical database must use only those segments and physical and logical relationship paths defined in the physical DBD referenced by the logical DBD.
  • The path used to connect a parent and child in a logical database must be defined as a physical relationship path or a logical relationship path in the physical DBD referenced by the logical DBD.
  • Physical and logical relationship paths can be mixed in a hierarchical segment path in a logical database.
  • Additional physical relationship paths, logical relationship paths, or both paths can be included after a logical relationship is crossed in a hierarchical path in a logical database. These paths are included by going in upward directions, downward directions, or both directions, from the destination parent. When proceeding downward along a physical relationship path from the destination parent, direction cannot be changed except by crossing a logical relationship. When proceeding upward along a physical relationship path from the destination parent, direction can be changed.
  • Dependents in a logical database must be in the same relative order as they are under their parent in the physical database. If a segment in a logical database is a concatenated segment, the physical children of the logical child and children of the destination parent can be in any order. The relative order of the children or the logical child and the relative order of the children of the destination parent must remain unchanged.
  • The same concatenated segment type can be defined multiple times with different combinations of key and data sensitivity. Each must have a distinct name for that view of the concatenated segment. Only one of the views can have dependent segments. The following figure shows the four views of the same concatenated segment that can be defined in a logical database. A PCB for the logical database can be sensitive to only one of the views of the concatenated segment type.
Figure 4. Single concatenated segment type defined multiple times with different combinations of key and data sensitivity
Root is physical parent segment type. Below it are four concatenated segments types: LC (K) and DP (K), LC (K) and DP (D), LC (D) and DP (K), LC (D) and DP (D).
LC
Logical child segment type
DP
Destination parent segment type
K
KEY sensitivity specified for the segment type
D
DATA sensitivity specified for the segment type