We've several tables with foreign secrets. I have checked their CREATE claims, and there is no 'ON Remove CASCADE' option enabled anywhere.
I must discover whether you'll be able to remove Parent, and all sorts of the attached rows in Child with supplying some command throughout the DELETION of row within the Parent.
It is a valid option, The code below works not surprisingly.
DROP TABLE IF EXISTS TestFoo; CREATE TABLE TestFoo ( Foo INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(Foo) ) ENGINE=InnoDB; DROP TABLE IF EXISTS TestBar; CREATE TABLE TestBar ( Bar INT NOT NULL AUTO_INCREMENT, Foo INT, PRIMARY KEY(Bar), FOREIGN KEY bar_foo (Foo) REFERENCES TestFoo (Foo) ON DELETE CASCADE ) ENGINE=InnoDB; INSERT TestFoo VALUES (NULL),(NULL),(NULL),(NULL); INSERT TestBar(Foo) VALUES (1),(2),(3),(4); SELECT * FROM TestBar; DELETE FROM TestFoo WHERE Foo = 2 OR Foo = 3; SELECT * FROM TestBar;
If there's no ON Remove CASCADE on the table, you could attempt applying it having a AFTER Remove trigger.
Otherwise, ON Remove CASCADE could be defined easily. However, be careful, particularly if a young child table has multiple constraints.