Databases · Junior · Question 3 of 75
What is a foreign key?
- ✓Correct answer: A column that references the primary key (or a unique key) of another table, and the database checks that the referenced row exists
- 2A key imported from another database server
- 3A key used to encrypt the table
Explanation
For example, orders.user_id references users.id. The database rejects an order for a non-existent user. ON DELETE CASCADE or ON DELETE SET NULL define what happens when the referenced row is deleted.