In SQL, primary keys and foreign keys are used to establish relationships between tables.

A primary key is a column or combination of columns that uniquely identify each row in a table.

Primary keys are used to enforce data integrity and ensure that each row in the table is unique and identifiable.

A table can have only one primary key, and primary keys cannot contain NULL values.

A foreign key is a column or combination of columns in one table that refers to the primary key of another table.

A foreign key column in one table must match the data type of the primary key column in the other table.

Foreign keys are defined using the FOREIGN KEY constraint, which is added to the column or columns

When a row is deleted from a table with a primary key, the corresponding rows in related tables will also be affected, based on the foreign key constraint