Foreign Keys
Foreign keys define a relationship between two tables. A foreign key is a single column or a group of
columns that is used to create and impose a relationship, or link, between a parent table and a child table.
Foreign keys are created when the column or columns of the primary key (from the primary key table) are
referenced by the column or columns in another table (the foreign key table). As discussed in the previous
section, the ContactID column in the Person.Contact table is a primary key. Figure 10-3 shows that the
ContactID column has been included or added to the HumanResources.Employee table, becoming a
foreign key in this table.
Figure 10-4 shows the two tables, Person.Contact and HumanResources.Employee, with the primary
key/foreign key relationship defined. The line between the two tables does not create the relationship
but illustrates the association between the two tables.
However, simply adding a reference column in another table (such as the HumanResources.Employee
table) does not create a primary key/foreign key relationship.
Pages:
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350