Primary key: identifies a row in its own table.
Foreign key: references a key in another table.
Example:
customers --------- id ← primary key orders ------ customer_id ← foreign key
It establishes a relationship between tables.
SQL · Keys, Schema & CTEs
Primary key vs foreign key?
Primary key: identifies a row in its own table.
Foreign key: references a key in another table.
Example:
customers --------- id ← primary key orders ------ customer_id ← foreign key
It establishes a relationship between tables.
🎯 Put this concept into practice
Solidify this answer with real hands-on interview drills in the browser studio.