One-To-One Relationships

One-to-one relationships are simpler but often less common than 1-to-N and M-to-N relationships. These relationships can often be handled by adding a data item to a record and using an existing set.

One-To-One Relationships on a Single Data Set

For example, assume that the relationship of being married is one-to-one. If you have a single data set of people, you could represent this with a data set or an entity-level diagram as shown in Figure D–2.

Figure 52. One-To-One Relationship on a Single Data Set

One-To-One Relationship on a Single Data Set

In a diagram such as Figure D–2, a rectangle represents a disjoint data set (in this instance, PEOPLE), and it normally corresponds to some intuitively understood entity in the situation being modeled. A diamond represents a relationship between the records of one or two disjoint data sets (in this instance, SPOUSE), and the arcs (the lines joining the rectangle to the diamond) are labeled to indicate the type of relation: 1-to‑1, 1-to‑N, or M‑to‑N (with M and N arbitrary).

Suppose that the name of each person is unique. Then the following DASDL description represents the situation:

PEOPLE DATA SET
 (
  NAME           ALPHA(24);
  SPOUSENAME     ALPHA(24); % NULL IF NOT MARRIED
     .
     .
     .
 );
 NAMESET SET OF PEOPLE KEY(NAME);

Given a record of the PEOPLE data set, the record for the spouse, if any, can be found using NAMESET with NAME=SPOUSENAME.

One-To-One Relationships Between Two Data Sets

The same technique works when two data sets are involved. Suppose you have a MALES and a FEMALES data set. Then you could represent the marriage relation at the data set level as shown in Figure D–3.

Figure 53. One-To-One Relationships Between Two Data Sets

One-To-One Relationships Between Two Data Sets

The following DASDL description represents the situation:

MALES DATA SET
 (
  NAME           ALPHA(24);
  WIFENAME       ALPHA(24); % NULL IF NOT MARRIED
     .
     .
     .
 );
 MALESET SET OF MALES KEY NAME;
FEMALES DATA SET
 (
  NAME           ALPHA(24);
  HUSBANDNAME    ALPHA(24); % NULL IF NOT MARRIED
       .
       .
       .
 );
 FEMALESET SET OF FEMALES KEY NAME;

Given a record of the MALES (FEMALES) data set, the record of the spouse in the FEMALES (MALES) data set can be found by using FEMALESET (MALESET) with NAME = WIFENAME (HUSBANDNAME).