
many, there is only one FD. When all relationships are
“many” (Figure 5.5d), the relationship table is all one com-
posite key unless the relationship has its own attributes. In
that case, the key is the composite of all three keys from
the three associated entities.
Foreign key constraints on delete and update for ter-
nary re
lationships transformed to SQL tables must always
be cascade because each entry in the S QL table depend s
on the current value of, or existence of, the referenced
primary key.
Generalization and Aggregation
The transformation of a generalization abstraction can
produce separate SQL tables for the generic or supertype
entity and each of the subtypes (Figure 5.7 for the ER
model and Figur
e 5.8 for UML). The table derived from
the supertype entity contains the supertype entity key and
all common attributes. Each table derived from subtype
entities contains the supertype entity key and only the
attributes that are specific to that subtype. Update integrity
is maintained by requiring all i nsertions and deletions
to occur in both the supertype table and relevant subtype
table—that is, the foreign key constraint cascade must
be used. If the update is to the primary key of the super-
type table, then all subtype tables as well as the supertype
table m ust be updat ed. An update to a non ke y attribute
affects either the supertype or one subtype table, but not
both. The transformation rules (and integrity rules) are
thesameforboththedisjointandoverlappingsubtype
generalizations.
Another approach is to have a single table that includes
al
l attr
ibutes from the supertype and subtypes (the whole
hierarchy in one table) with nulls used when necessary.
A third possibility is one table for each subtype, pushing
down the common attributes into the specific subtypes.
There are advantages and disadvantages to each of these
three approaches. Several software tools are now supporting
all three options (Fowler, 2003; Ambler, 2003).
Database practitioners often add a discriminator to the
supertype when they implement generalization. The dis-
criminator is an attribute that has a separate value for each
Chapter 5 TRANSFORMING THE CONCEPTUAL DATA MODEL TO SQL 95