The short answer
: identifies a row in its own table.
: references a key in another table.
Example:
customers --------- id ← primary key orders ------ customer_id ← foreign key
It establishes a relationship between tables.
Free. Runs in your browser, no install.
SQL · Keys, Schema & CTEs
Primary key vs foreign key?
The short answer
: identifies a row in its own table.
: references a key in another table.
Example:
customers --------- id ← primary key orders ------ customer_id ← foreign key
It establishes a relationship between tables.
Lock it in with a real drill
You remember an answer longer once you have used it. Try a hands-on problem on this concept.