What is the difference between Primary Key and Foreign Key? - ProProfs Discuss
Advertisement

What is the difference between Primary Key and Foreign Key?

Asked by R. Jones, Last updated: Apr 19, 2024

+ Answer
Request
Question menu
Vote up Vote down

1 Answer

D. gray

D. gray

Building buildings and building intelligence

D. gray
D. gray, Builder, Builder, Las Vegas

Answered Aug 21, 2019

Keys are basic elements of the database relation, as they give a relationship between two tables and make sure that each record in a table is defined uniquely. Keys are one main table-level integrity component, and also help in Referential Integrity. In this article, the primary key and foreign key will be discussed. They actually help fetch data from a number of records stored in a table. In a relational database, the primary key happens to be a special key that helps to identify each record in a table with unique value across each row of the table.

Keys are basic elements of the database relation, as they give a relationship between two tables
On the other hand, a foreign key happens to be a field in a table, and it links two tables together. It refers to a group of columns or column itself which identifies the row of the table or another one uniquely. Another main difference between these keys is that NULL values can also be contained in foreign keys, while only a primary key can be contained in one relational database without allowing NULL values.

upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.