Suggest an editImprove this articleRefine the answer for “What does ON DELETE CASCADE do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)`ON DELETE CASCADE` is a rule for a foreign key that tells the database: if a record in the parent table is deleted, automatically delete every related record in the child table too - for example, deleting a department automatically deletes all of its employees. **Key point:** this is needed to avoid leaving "orphaned references" to records that no longer exist, and to simplify managing related data during deletes.Shown above the full answer for quick recall.Answer (EN)Image`ON DELETE CASCADE` is a rule for a **foreign key** that tells the database: > If a record in the parent table is deleted, automatically **delete every related record** in the child table. **Example:** Tables: - `Departments` (`ID`, `Name`) - `Employees` (`ID`, `Name`, `DepartmentID`) Creating a foreign key with a cascade: ```sql ALTER TABLE Employees ADD CONSTRAINT fk_department FOREIGN KEY (DepartmentID) REFERENCES Departments(ID) ON DELETE CASCADE; ``` ### What happens - If a department is deleted from the `Departments` table, every employee belonging to that department **also gets automatically deleted** from the `Employees` table. **Why this is needed:** - To avoid leaving **"orphaned references"** to records that no longer exist. - It simplifies managing related data, especially during deletes. > Put simply, `ON DELETE CASCADE` automatically removes every dependent record, keeping the database consistent.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.