Recall & Review
beginner
What does CASCADE DELETE do in a database?
It automatically deletes all related rows in child tables when a row in the parent table is deleted.
Click to reveal answer
beginner
Why is CASCADE DELETE useful?
It helps keep data consistent by removing dependent records without needing extra queries.
Click to reveal answer
beginner
What happens if you delete a parent row without CASCADE DELETE set on its foreign keys?
The database will prevent the deletion if child rows exist, to avoid orphaned data.
Click to reveal answer
intermediate
How can you preview which rows will be deleted by a CASCADE DELETE?
By running SELECT queries on child tables filtering by the parent row's key before deleting.
Click to reveal answer
intermediate
Write a simple SQL command to create a foreign key with CASCADE DELETE.
ALTER TABLE child_table ADD CONSTRAINT fk_name FOREIGN KEY (parent_id) REFERENCES parent_table(id) ON DELETE CASCADE;
Click to reveal answer
What does ON DELETE CASCADE do in a foreign key constraint?
✗ Incorrect
ON DELETE CASCADE means deleting a parent row will also delete all related child rows automatically.
If you want to check which child rows will be deleted by a CASCADE DELETE, what should you do?
✗ Incorrect
You preview the effect by selecting child rows linked to the parent before deleting.
What happens if you delete a parent row without ON DELETE CASCADE and child rows exist?
✗ Incorrect
The database blocks deletion to avoid orphaned child rows.
Which SQL clause defines CASCADE DELETE behavior?
✗ Incorrect
ON DELETE CASCADE sets the delete behavior to cascade deletions.
Why should you preview CASCADE deletes before running them?
✗ Incorrect
Previewing helps prevent unintended data loss by showing what will be deleted.
Explain in your own words what CASCADE DELETE does and why it is important.
Think about what happens to connected data when you remove a main record.
You got /3 concepts.
Describe how you would preview the rows affected by a CASCADE DELETE before actually deleting.
Imagine checking what will be lost before pressing delete.
You got /3 concepts.