Bird
0
0

You have this foreign key constraint:

medium📝 Debug Q6 of 15
SQL - Table Constraints
You have this foreign key constraint:
FOREIGN KEY (fk_col) REFERENCES parent(id) ON UPDATE CASCADE

You try to update the parent key but get an error. What could be a likely cause?
AON UPDATE CASCADE is not supported by the database.
BThe child table has rows with fk_col values that do not match any parent id.
CThe parent key is not a primary key.
DThe foreign key column is not indexed.
Step-by-Step Solution
Solution:
  1. Step 1: Check foreign key integrity

    If child rows have fk_col values not matching any parent id, update can fail due to constraint violation.
  2. Step 2: Understand ON UPDATE CASCADE requirements

    ON UPDATE CASCADE requires existing matching keys; otherwise, update fails.
  3. Final Answer:

    The child table has rows with fk_col values that do not match any parent id. -> Option B
  4. Quick Check:

    Foreign key mismatch causes update error [OK]
Quick Trick: Foreign key mismatch causes update errors [OK]
Common Mistakes:
MISTAKES
  • Assuming ON UPDATE CASCADE is unsupported
  • Thinking parent key must be indexed
  • Believing parent key can't be non-primary

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes