Difference between primary key and foreign key


Sql Question

A primary key uniquely identifies a record in the relational database table, whereas a foreign key refers to the field in a table which is the primary key of another table. A table can contain only one primary key whereas one or more than one foreign key.

Primary Key: As the name suggest, its a way to distinguish between each record in a Relational Database Table.

Foreign Key: Its a dependent key on Primary key (AKA Parent Child relationship.)

its a 1:N relationship between Primary Key and Foreign Key.

Both in combination are used to maintain the referential integrity of a Relational Database.