Skip to content
Bugwise
Menu

Foreign key

Also called: FK

A column that points to the primary key of a row in another table, like orders.user_id → users.id.

Definition

Foreign keys link tables together and are what you join on. If the database doesn't enforce them, you can get orphan rows: records that point to something that no longer exists. Testers look for these after deletes and migrations.

In practice

An order item with order_id = 1016 when there is no order 1016 is an orphan row, usually caused by deleting an order but not its items.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.