Question

I have two InnoDB tables:

CREATE TABLE master(
   id INTEGER UNSIGNED NOT NULL auto_increment PRIMARY KEY
);

CREATE TABLE details(
   id INTEGER UNSIGNED NOT NULL auto_increment PRIMARY KEY, 
   master_id INTEGER UNSIGNED NOT NULL, CONSTRAINT `byMasterId` 
   FOREIGN KEY (`master_id`) REFERENCES `master`(`id`) ON UPDATE CASCADE ON DELETE CASCADE 
);

And I need a BEFORE UPDATE trigger on master table to do some validation (and cancel an update in some cases). Do cascade changes in details table occur after BEFORE UPDATE trigger?

Was it helpful?

Solution

Yes, the "before update" trigger runs before the update on the master table, and the cascade happens after the update on the master table.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top