1. For two tables
Order table tb_order (orderid ,****)
Order and dish table tb_order_dish (orderid, dishid ,***)
2. Select the orderid of the Order table as the foreign key, and the orderid of the order and dish table as the subkey.
The SQL statement should be:
Drop table if exists 'tb _ order_dish ';
Create Table 'tb _ order_dish '(
'Orderid' int (11) not null default '0' comment 'order id ',
'Dishid 'int (11) not null default '0' comment 'dish id ',
'Dishnumber' varchar (10) default null comment' Number of dishes ',
Primary Key ('orderid', 'dishid ')
) Engine = InnoDB default charset = gb2312 comment = 'order table ';
Alter table 'tb _ order_dish'
Add constraint 'orderanddish' foreign key ('orderid') References 'tb _ order' ('orderid') on Delete cascade on update cascade;
3. You can also use a tool to create a constraint in tb_order_dish and set Partially Matching on Delete cascade.
4. In this way, you can delete cascade updates.