thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Intermediate

Cascading Referential Action

Foreign key options (CASCADE, SET NULL, SET DEFAULT, NO ACTION, RESTRICT) that define what happens to child rows when a parent row changes.

Definition

ON DELETE CASCADE removes child rows when the parent is deleted, ON DELETE SET NULL clears the foreign key, and NO ACTION or RESTRICT blocks the change. ON UPDATE options work the same way for key updates. Cascades are convenient but can delete large amounts of data unexpectedly.

Example

FOREIGN KEY (OrderID) REFERENCES Orders(OrderID) ON DELETE CASCADE

Exam tip

If a scenario wants child rows removed automatically with their parent, choose ON DELETE CASCADE; to keep the children but detach them, choose SET NULL.

Related terms