Database Reference
In-Depth Information
One-to-Many Relationships
A one-to-many relationship exists between a pair of tables when a single record in the
first table can be related to many records in the second table, but a single record in the
second table can be related to only one record in the first table. (The parent/child model I
used to describe a one-to-one relationship works here as well. In this case, the table on the
“one” side of the relationship is the parent table, and the table on the “many” side is the
childtable.)Youestablishaone-to-manyrelationshipbytakingacopyoftheparenttable's
primary key and incorporating it within the structure of the child table, where it becomes a
foreign key.
The example in Figure 3.14 illustrates a typical one-to-many relationship. A single record
in the AGENTS table can be related to one or more records in the ENTERTAINERS
table, but a single record in the ENTERTAINERS table is related to only one record in the
AGENTS table. As you probably have already guessed, A GENT ID is a foreign key in the
ENTERTAINERS table.
Figure 3.14. An example of a one-to-many relationship
This is by far the most common relationship that exists between a pair of tables in a data-
base. It is crucial from a data-integrity standpoint because it helps to eliminate duplicate
data and to keep redundant data to an absolute minimum.
Search WWH ::




Custom Search