You are on page 1of 1

Primary key Foreign Key

Primary key uniquely identify a record in the table. Foreign key is a field in the table that is primary key in another table.

Primary Key can't accept null values. Foreign key can accept multiple null values.

By default, Primary key is clustered index and data in the database table is Foreign key do not automatically create an index, clustered or non-clustered.
physically organized in the sequence of clustered index. You can manually create an index on foreign key.

We can have only one Primary key in a table. We can have more than one foreign key in a table.

Primary Key Unique Key

Primary Key can't accept null values. Unique key can accept only one null value.
By default, Primary key is clustered index and By default, Unique key is a unique non-clustered
data in the database table is physically organized index.
in the sequence of clustered index.
We can have only one Primary key in a table We can have more than one unique key in a
table
Primary key can be made foreign key into In SQL Server, Unique key can be made foreign
another table key into another table.

You might also like