views:

132

answers:

1

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?

+1  A: 

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

Ike Walker