IT lexicon › Database › Cascade Delete

Cascade Delete

Database På svenska → Updated: 2026-11-10

Automatic removal of child records when a parent record is deleted, defined as a rule on a foreign key.

If a table holds a foreign key (e.g., `order_id` in an order-line table) and you delete the parent order, what happens to the orphan lines? Without cascade-delete, you'd have order lines pointing to nothing — referential integrity violated. With `ON DELETE CASCADE`, the lines vanish automatically alongside the order. The alternative, `ON DELETE RESTRICT`, forbids the deletion entirely if child records exist.

It requires forethought — automatically deleting data can be dangerous if you didn't expect it.

← Back to the lexicon