Reprinted from: http://blog.163.com/inflexible_simple/blog/static/1676946842011616102543931/
FOREIGN key constraint meaning for child table:
If a candidate key is not found in the parent table, INSERT/UPDATE&NBSP is not allowed on the child table;
The meaning of the foreign key constraint to the parent table:
when update/delete on a parent table to update or delete a candidate key that has one or more matching rows in the child table, the behavior of the parent table is determined by the on update/on delete clause that is specified when the foreign key of the child table is defined, InnoDB supports 5 ways of ,
. Cascade mode
when Update/delete record on parent table, synchronize update/ Delete the matching record of the child table;
on DELETE cascade available from mysql3.23.50, on UPDATE cascade mysql4.0.8 from  
. Set NULL mode
when Update/delete records on the parent table, set the column of matching records on the child table to null
Note that the foreign key column of the child table cannot be null
on Delete set Null starting from mysql3.23.50 available; On update set NULL &NBSP available from mysql4.0.8;
. No action mode
If there is a matching record in the child table, the Update/delete action for the parent table corresponding to the candidate key is not allowed
This is the ANSI SQL-92 standard, starting from mysql4.0.8 support
. Restrict mode
No action, check foreign KEY constraint immediately
. Set default mode The
Parser recognizes this action, but InnoDB does not recognize it and does not know what it means ...
Note: Trigger is not affected by foreign key cascade behavior, that is, trigger
Cascade in MySQL, NO ACTION, Restrict, SET NULL