What is a key risk when deleting rows referenced by foreign keys in SQL?
2025
What is a key risk when deleting rows referenced by foreign keys in SQL?
- A.
Automatic table encryption
- B.
Duplicate primary keys
- C.
Improved query performance
- D.
Orphaned child records if ON DELETE CASCADE isn't used
Attempted by 168 students.
Show answer & explanation
Correct answer: D
When you delete a row from a parent table that is actively referenced by a foreign key in a child table, you risk breaking referential integrity.
If the database schema does not explicitly block the deletion (e.g., via a RESTRICT or NO ACTION constraint) or automatically clean up the child table using a referential action like ON DELETE CASCADE, the rows in the child table will lose their valid parent association. These left-behind rows are known as orphaned child records, meaning they contain a foreign key value pointing to a parent record that no longer exists.