Database
Foreign Key
Added: June 23, 2026
Definition
A Foreign Key is a column (or set of columns) in one table that references the Primary Key of another table, creating a relationship between the two tables and enforcing referential integrity.
What Problem It Solves
It prevents invalid or orphan records by ensuring that a value in the child table must exist in the parent table.
What Happens If Not Used
Data can become inconsistent, e.g., records may reference non-existent entries, leading to broken relationships.
Easy Wording
It is a link between two tables that makes sure data in one table matches valid data in another table.
Technical Example
An Order table cannot store a Customer ID that does not exist in the Customer table. Customer(CustomerID PK) Orders(OrderID PK, CustomerID FK) Here, Orders.CustomerID is a foreign key referencing Customer.CustomerID.