Bird
0
0

A foreign key constraint with ON DELETE CASCADE is not deleting child rows as expected. What could be the problem?

medium📝 Debug Q7 of 15
SQL - Table Constraints
A foreign key constraint with ON DELETE CASCADE is not deleting child rows as expected. What could be the problem?
AThe foreign key constraint was created without ON DELETE CASCADE.
BThe parent table has no rows.
CThe child table has no foreign key column.
DThe database engine does not support foreign keys.
Step-by-Step Solution
Solution:
  1. Step 1: Check foreign key constraint definition

    If ON DELETE CASCADE was not specified, child rows won't be deleted automatically.
  2. Step 2: Verify other options

    Parent table having no rows or child table missing foreign key column would cause other errors, not this behavior.
  3. Final Answer:

    The foreign key constraint was created without ON DELETE CASCADE. -> Option A
  4. Quick Check:

    ON DELETE CASCADE must be defined to delete child rows [OK]
Quick Trick: ON DELETE CASCADE must be explicitly set [OK]
Common Mistakes:
MISTAKES
  • Assuming CASCADE is default behavior
  • Ignoring constraint definition
  • Blaming database engine without checking

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes