What's a foreign key?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top