Wednesday 28 October 2020

Difference between Primary key and Foreign key in DBMS (Primary key vs. Foreign key)

 

Differences between Primary key & Foreign key:


Primary Key
Foreign Key

Helps you to uniquely identify a record in the table.

It is a field in the table that is the primary key of another table.

It never accepts null values.

It may accept multiple null values.

Primary key is a clustered index and data in the DBMS table are physically organized in the sequence of the clustered index.

A foreign key cannot automatically create an index, clustered or non-clustered. However, you can manually create an index on the foreign key.

You can have the single Primary key in a table.

You can have multiple foreign keys in a table.

No comments:

Post a Comment