Foreign key
A column pointing to another table's primary key, which relates the 2 tables.
Example
orders.user_id = 42 says that order belongs to user 42.
Test yourself: Foreign key
SQL databases
A foreign key points to another table's primary key.
orders.user_id = 42 points to users.id = 42. That's why the database can block an order for user 99 if user 99 doesn't exist.
0/1
â–¶ Play