CS FundamentalsEasyWipro · Cognizant pattern
A foreign key column is declared `ON DELETE CASCADE`. If the referenced (parent) row is deleted, what happens to the child rows referencing it?
- A. The database automatically deletes all the matching child rows as part of the same operation
- B. The foreign key column in the child rows is automatically set to NULL
- C. Nothing happens to the child rows; the foreign key constraint is simply ignored on delete
- D. The delete on the parent row fails until all child rows are manually removed
Correct answer: A. The database automatically deletes all the matching child rows as part of the same operation
ON DELETE CASCADE propagates the delete: removing a parent row automatically removes every child row whose foreign key pointed to it, keeping referential integrity without the application needing to delete children explicitly. ON DELETE SET NULL would instead null out the FK column, and the default (NO ACTION/RESTRICT) is what blocks the parent delete until children are handled.
More DBMS and SQL questions
- A schema uses salary DECIMAL(8,2) for a salary column. Which value would be REJECTED when inserted?
- A column is declared VARCHAR(10) vs. CHAR(10). For a value like 'cat' (3 characters), which statement is correct about storage and…
- A query planner chooses a full table scan over using an available index on a WHERE column. Which scenario makes this the RIGHT choice, not…
- Which statement about a query execution plan using a hash join versus a nested-loop join is correct?
- A sort-merge join requires both input relations to be sorted on the join key (or sorted as part of the plan). When is sort-merge join…
- A transaction executes BEGIN; UPDATE accounts SET balance = balance - 100 WHERE id = 1; UPDATE accounts SET balance = balance + 100 WHERE…