What is Foreign Key?
A foreign key is a column in one table that refers to the primary key of another table, linking their rows together.
Foreign Key explained
In an orders table, customer_id is a foreign key to customers.id. It says which customer placed each order, and it is the column you join on to bring customer details next to order amounts.
Databases can enforce foreign keys so an order cannot point to a customer who does not exist. Exports and spreadsheets do not, so orphaned references are a common data-quality problem.
Example
order_items.order_id is a foreign key to orders.id: each line item belongs to exactly one order, while an order can have many line items.