Bird
0
0

What happens to child rows when a parent row is deleted if the foreign key is defined with ON DELETE RESTRICT?

easy📝 Conceptual Q1 of 15
SQL - Table Constraints
What happens to child rows when a parent row is deleted if the foreign key is defined with ON DELETE RESTRICT?
AChild rows have their foreign key set to NULL.
BChild rows are automatically deleted.
CChild rows remain unchanged and the parent row is deleted.
DThe delete operation on the parent row is blocked if child rows exist.
Step-by-Step Solution
Solution:
  1. Step 1: Understand ON DELETE RESTRICT behavior

    ON DELETE RESTRICT prevents deletion of a parent row if any child rows reference it.
  2. Step 2: Apply to the scenario

    If child rows exist, the parent row cannot be deleted, so the delete operation is blocked.
  3. Final Answer:

    The delete operation on the parent row is blocked if child rows exist. -> Option D
  4. Quick Check:

    ON DELETE RESTRICT = Block delete if children exist [OK]
Quick Trick: RESTRICT blocks parent delete if children exist [OK]
Common Mistakes:
MISTAKES
  • Thinking child rows get deleted automatically
  • Assuming foreign keys are set to NULL
  • Believing parent deletes always succeed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes