A primary-key field and a foreign-key field don't need to have the same name to be linkable.
They do need to contain the same data. Remember, the RDBMS doesn't identify the link between the tables, the designer does.
![]() |
||
Lesson 14
Objective |
Database Foreign keys
Define foreign keys. |
|
|
When you create a database to manage information for a business, it is common for tables in the database to have columns in
common.
In the following illustration, the CUSTOMER and ORDER tables share the CustID column.
The difference between the CustID field in the CUSTOMER table and its counterpart in the ORDER table is that the CustID field is the
primary-key field for the CUSTOMER table but not for the ORDER table. When table A contains a field that is the primary-key field in
table B, that field in table A is referred to as a foreign key .
Foreign Key - Primary Key
Foreign key: A field (or combination of fields) used to link tables; a corresponding primary key field occurs in the same database.
A foreign key field can be identified with the primary key of more than one table.
This is not a requirement. Benefits of Foreign Keys
While foreign keys don't uniquely identify records in their tables, they do provide an important benefit. They enable you to
create links between tables that share fields. Again, consider the CUSTOMER and ORDER tables.
The next lesson describes referential integrity. Relational Constructs Quiz
Before you move on to the next lesson, click the Quiz link below to reinforce your understanding of foreign keys.
Relational Constructs Quiz |
||
|
|
||
