What are primary keys and foreign keys?
What are primary keys and foreign keys
Hi friends
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 9, 2012, 4:20 AM EST
Satyapriya NayakRank #47 · 31.5K reputationPosted Nov 9, 2012, 5:55 AM EST
http://www.1keydata.com/sql/sql-foreign-key.html
Vishnujeet KumarRank #1,019 · 1.9K reputationPosted Nov 9, 2012, 7:08 AM EST
very good video tutorial.
https://www.youtube.com/watch?v=8iIvyNPwruU
https://www.youtube.com/user/dnfvideo/videos?view=0
Vithal WadjeRank #19 · 47.2K reputationPosted Nov 19, 2012, 12:00 AM EST
The PRIMARY KEY constraint uniquely identifies each record in a database table.
Primary keys must contain unique values.
A primary key column cannot contain NULL values.
Each table should have a primary key, and each table can have only ONE primary key
A FOREIGN KEY in one table points to a PRIMARY KEY in another table.
The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.
The FOREIGN KEY constraint also prevents that invalid data form being inserted into the foreign key column, because it has to be one of the values contained in the table it points to.