Database Reference
In-Depth Information
Engine
Boxcar 10
Boxcar 20
Boxcar 15
Figure 5-39
Sample Entity Instances
for the Data Model in
Figure 5-38
First Boxcar
Relationship
Boxcar
Relationships
Figure 5-39 shows example entity instances that illustrate this data model. Not surpris-
ingly, this set of entity instances looks just like a train.
An alternative model is to use the relationship to represent the BOXCAR behind. Either
model works. Other examples of 1:1 recursive relationships are the succession of U.S. presi-
dents, the succession of deans in a college of business, and the order of passengers on a
waiting list.
1:N Recursive Relationships
The classic example of a 1:N recursive relationship occurs in organizational charts, in which an
employee has a manager who may, in turn, manage several other employees. Figure 5-40 shows
an example organizational chart. Note that the relationship between employees is 1:N.
Figure 5-41 shows a data model for the managerial relationship. The crow's foot indicates
that a manager may manage more than one employee. The relationship is optional to optional
because one manager (the president) has no manager and because some employees manage
no one.
Another example of a 1:N recursive relationship concerns maps. For example, a world map
has a relationship to many continent maps, each continent map has a relationship to many
nation maps, and so forth. A third example concerns biological parents where the relationship
from PERSON to PERSON is shown by tracing either mother or father (but not both).
N:M Recursive Relationships
N:M recursive relationships occur frequently in manufacturing applications, where they are
used to represent bills of materials. Figure 5-42 shows an example.
The key idea of a bill of materials is that one part is composed of other parts. A child's red
wagon, for example, consists of a handle assembly, a body, and a wheel assembly, each of which
is a part. The handle assembly, in turn, consists of a handle, a bolt, a washer, and a nut. The
wheel assembly consists of wheels, axles, washers, and nuts. The relationship among the parts
is N:M because a part can be made up of many parts and because a part (such as washers and
nuts) can be used in many parts.
The data model for a bill of materials is shown in Figure 5-43. Notice that each part has
an N:M relationship to other parts. Because a part need not have any component parts and
because a part need not have any parts that contain it, the minimum cardinality is optional to
optional.
Figure 5-40
Organizational Chart
Relationships
Sarah
John
Robin
Bob
Tae
Arthur
Jonathan
Andie
Kyle
Alex
Robyn
Search WWH ::
Custom Search