Labels

Sunday, 27 December 2015

SQL Server - Difference between Primary Key and Foreign Key

The below are the key differences between PK and FK.

S.No

Primary Key

Foreign Key

1 Primary key uniquely identify a record in the table. Foreign key is a field in the table that is
primary key in another table. 
2
Primary Key cannot accept null values

Foreign key can accept multiple null values. 
3



By default, Primary key is clustered index and data in the database table is physically organized in the sequence of clustered index.

While Foreign key is non-clustered index.
4 We can have only one Primary key in a table.  We can have more than one foreign key
in a table. 

No comments:

Post a Comment