KnowledgeBoat Logo
|

Computer Science

Differentiate between primary key and foreign key.

Relational Database

3 Likes

Answer

Primary KeyForeign Key
Primary Key is a column or group of columns in a table that uniquely identify every row in that table.A foreign key is an attribute whose value is derived from the primary key of another table. A foreign key is used to represent the relationship between two tables.
Primary key cannot have Null values.Foreign key can have Null values.
There can be only one primary key in a table.Multiple foreign keys can exist in a table.
It is used to enforce entity integrity and ensure data uniqueness.It is used to enforce referential integrity and maintain data consistency across related tables.

Answered By

1 Like


Related Questions