Database Reference
In-Depth Information
One-to-One Relationships
A pair of tables bears a one-to-one relationship when a single record in the first table is
related to only one record in the second table, and a single record in the second table is
relatedtoonlyonerecordinthefirsttable.Inthistypeofrelationship,onetableservesasa
“parent” table and the other serves as a “child” table. You establish the relationship by tak-
ing a copy of the parent table's primary key and incorporating it within the structure of the
child table, where it becomes a foreign key. This is a special type of relationship because it
is the only one in which both tables may actually share the same primary key.
Figure 3.13 shows an example of a typical one-to-one relationship. In this case,
EMPLOYEESistheparenttableandCOMPENSATIONisthechildtable.Therelationship
between these tables is such that a single record in the EMPLOYEES table can be
related to only one record in the COMPENSATION table, and a single record in the
COMPENSATIONtablecanberelatedtoonlyonerecordintheEMPLOYEEStable.Note
that E MPLOYEE ID is indeed the primary key in both tables. However, it will also serve the
role of a foreign key in the child table.
Figure 3.13. An example of a one-to-one relationship
Search WWH ::




Custom Search