What's a foreign key?

S

stacymae

I don't understand the foreign key thing, I know a good database isnt
supposed to have duplicateing fields in diffrent tables but to link the
tables I had to create duplicating fields. Now how do I link the data without
having to fill in the duplicated fields in each table?
 
A

Allen Browne

Open the Northwind sample database.
Open the Relationships window (Tools menu).

In this view, CustomerID is bold in the Customers table.
That's because it is the primary key to the table.

But the Orders table also has a field named CustomerID, and you can see the
line joining it to Customers.CustomerID. It shows there can be many orders
for the same customer.

In the Orders table, CustomerID is a foreign key. A foreign key is a field
like that - it relates the the key field in another table.
 
Top