Questions: Referential Integrity and Cascading Delete/Update Actions

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A university database has a `students` table and an `enrollments` table with a foreign key referencing students. After a student withdraws, an administrator deletes the student's record. The university wants to keep enrollment records for institutional history, but with the student reference cleared. Which ON DELETE action achieves this?

ACASCADE — deletes the student and automatically removes all their enrollment records
BSET NULL — keeps enrollment records but sets the student_id foreign key to NULL
CRESTRICT — prevents the delete until all enrollment records are removed manually
DSET DEFAULT — replaces the student_id with a placeholder value defined at table creation
Question 2 Multiple Choice

A developer applies ON DELETE CASCADE to every foreign key in a schema 'to avoid constraint violation errors.' They then delete a single top-level department record. What is the most dangerous likely consequence?

AThe delete will fail because cascading across multiple tables is not permitted
BChild rows (employees, projects, budgets) will be automatically deleted, potentially removing far more data than the developer intended
CThe foreign key constraints will be silently ignored for the operation
DChild rows will be preserved and their foreign keys set to NULL automatically
Question 3 True / False

Referential integrity enforcement applies primarily when you delete rows from a parent table — not during INSERT or UPDATE operations on the child table.

TTrue
FFalse
Question 4 True / False

Using ON DELETE CASCADE is most appropriate when child rows have no meaningful existence independent of their parent — for example, order line items that belong to a specific order.

TTrue
FFalse
Question 5 Short Answer

Explain the difference between a 'composition' relationship and an 'association' relationship in database design, and give one example of each showing why they call for different ON DELETE actions.

Think about your answer, then reveal below.