Before moving on to the next lesson, click the Quiz link below to check your understanding of key columns and primary keys.
Primary Key Quiz
|
||
Lesson 12
Objective
|
Concatenated primary keys
Define concatenated primary keys. |
|
|
In the preceding lesson we discussed primary-key columns, which contain values
that uniquely identify a record within a table. Sometimes a single column is not sufficient to distinguish a record from every other record in
a table. As an example, consider again the Line Item table:
No single column contains enough information to set a record apart from every other record in the table, though OrderNo and CDNo are the most
likely prospects. Unfortunately, an order can contain more than one CD and a CD can be part of more than one order.
It is possible to create a CDOrderID column, but there is an easier solution: Create a concatenated primary key based on the existing table columns. A concatenated primary key is a primary key made up of two or more columns. In the case of the Line Item table, each record is uniquely identified by the combined values of the OrderNo and CDNo columns located at the extreme left of the table. We are assuming a particular CD will not occur more than once in an order.
Concatenated primary keys need to follow two additional rules:
The next lesson describes all-key relations.
All-key relation: A relation in which every field is a member of the relation\'s primary key. Primary Key Quiz |
||
|
|
||