
the other entity, thus changing it to a foreign key. The addi-
tion of a foreign key due to a one-to-one relationship can
be made in either direction. One strategy is to maintain
the most natural parent–child relationship by putting the
parent key into the child table. Another strategy is based
on efficiency: Add the foreign key to the table with fewer
rows.
Every entity in a generalization hierarchy is transformed
into a table. Each of these tables contains the key of the
supertype entity; in reality, the subtype primary keys are
foreign keys as well. The supertype table also contains
nonkey values that are common to all the relevant entities;
the other tables contain nonkey values specific to each
subtype entity.
SQL constructs for these transformations may include
constraints for not null, unique, and foreign key. A primary
key must be specified for each table, either explicitly from
among the keys in the ER diagram or by taking the com-
posite of all attributes as the default key. Note that the pri-
mary key designation implies that the attribute is not null
and unique. It is important to note, however, that not all
DBMSs follow the ANSI standard in this regard—it may
be possible in some systems to create a primary key that
can be null. We recommend that you specify “not null”
explicitly for all key attributes.
Many-to-Many Binary Relationship
Transformation
In this step, every many-to-many binary relationship is
transformed into a table containing the keys of the entities
and the attributes of the relationship. The resulting table
will show the correspondence between specific instances
of one entity and those of another entity. Any attribute of
this correspondence, such as the elected office an engineer
has in a professional association (Figure 5.1f), is consid-
ered
intersection data and is added to the table as a non-
key attribute.
SQL constructs for this transformation may include
constraints
for not null.
The unique constraint is not used
here because all keys are composites of the participating
primary keys of the associated entities in the relationship.
Chapter 5 TRANSFORMING THE CONCEPTUAL DATA MODEL TO SQL 105