What Is Primary Key?
⦁ The primary key is the unique identifier for the entire row, referring to one or more columns.
⦁ if there are more multiple columns for the primary key, then the set of primary key columns is known as a composite key.
What Is Foreign Key?
⦁ A primary key in another (foreign) table.
⦁ Foreign keys are used to map relationships between tables.
Primary Key vs Foreign Key
⦁ A primary key is used to ensure data in the specific column is unique.
⦁ A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables
⦁ It uniquely identifies a record in the relational database table.
⦁ It refers to the field in a table which is the primary key of another table.
⦁ Only one primary key is allowed in a table.
⦁ Whereas more than one foreign key is allowed in a table.
⦁ It is a combination of UNIQUE and Not Null constraints.
⦁ It can contain duplicate values and a table in a relational database.
⦁ It does not allow NULL values.
⦁ It can also contain NULL values.
⦁ Its value cannot be deleted from the parent table.
⦁ Its value can be deleted from the child table.
⦁ Its constraint can be implicitly defined on the temporary tables.
⦁ Its constraint cannot be defined on the local or global temporary tables.
The relational databases support many keys on It.
Like (Super Key - Candidate Key - Composite Key - Surrogate Key - Alternate Key)