Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Relationships?? Primary and Foreign Key

Status
Not open for further replies.

natemclain

Technical User
Jun 19, 2001
68
US
Can someone explain how you can tell the difference in a Primary Key & Foreign Key?? I was looking at the Northwind DB and noticed that the Order Details Table had 2 Primary Keys. But I don't understand how you can tell the difference in the two?? Also, how can you setup multiple Primary Keys on 1 table? Can that be done? SO you can tie a Part Number and a AutoNumber to the same part so that duplication doesn't happen?

Thanks for the ongoing help!

natemclain
 
A primary key is any feild, or combination of fields, that uniqely identifies each individual record in a table.

A foreign key is a key that's stored in , that points to the primary key in another table.

tblCust
Cust ID Name
(Primary key)
1 Microsoft
1 Microsoft

tblContact
ContactID Cust ID Name
(Primary key) (Foreign key)
1 1 Bill Gates
2 1 Fred Flintstone

A query could then pull up:
Cust ID Contact ID Custame Contact Name
1 1 Microsoft Bill Gates
1 2 Microsoft Fred Flintstone


Tyrone Lumley
augerinn@gte.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top