Questions: Primary Keys and Foreign Keys

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A developer deletes a row from the Customers table for a customer who has 5 active orders in the Orders table. The Orders.customer_id column is a foreign key referencing Customers.id, with no cascade behavior configured. What happens?

AThe customer is deleted and the 5 orders are automatically deleted as well
BThe customer is deleted and the orders' customer_id values are set to NULL
CThe database rejects the deletion with a constraint violation
DThe customer row is marked as deleted but retained until the orders are removed
Question 2 Multiple Choice

A developer proposes using users' email addresses as the primary key in the Users table since emails are unique per user. What is the primary risk of this design?

AEmail addresses are too long to be indexed efficiently by most databases
BPrimary keys must be integers; string values are not permitted
CEmail addresses can change, which would require updating every foreign key reference across all dependent tables
DEmail uniqueness cannot be guaranteed at the database level
Question 3 True / False

A primary key should typically consist of a single column.

TTrue
FFalse
Question 4 True / False

A foreign key column in one table should have the same name as the primary key column it references in another table.

TTrue
FFalse
Question 5 Short Answer

Why is enforcing referential integrity through database constraints preferable to relying on application code to check validity?

Think about your answer, then reveal below.