Golf

Section 2.2 Keys

First, let's discuss the concept of keys. A primary key is a column or set of columns that uniquely

identifies the rest of the data in any given row. For example, in the AntiqueOwners table, the OwnerID

column uniquely identifies that row. This means two things: no two rows can have the same OwnerID,

and, even if two owners have the same first and last names, the OwnerID column ensures that the two

owners will not be confused with each other, because the unique OwnerID column will be used

throughout the database to track the owners, rather than the names.

A foreign key is a column in a table where that column is a primary key of another table, which means

that any data in a foreign key column must have corresponding data in the other table where that

column is the primary key. In DBMS-speak, this correspondence is known as referential integrity. For

example, in the Antiques table, both the BuyerID and SellerID are foreign keys to the primary key of

the AntiqueOwners table (OwnerID; for purposes of argument, one has to be an Antique Owner before

one can buy or sell any items), as, in both tables, the ID rows are used to identify the owners or buyers

and sellers, and that the OwnerID is the primary key of the AntiqueOwners table. In other words, all of

this "ID" data is used to refer to the owners, buyers, or sellers of antiques, themselves, without having

to use the actual names.

                                        page: 1 from 1