Mysql adds multiple foreign keys/Adds Foreign keys/cascading constraints to the table
1. create table 'xh' ('id' int (100) unsigned not null AUTO_INCREMENT COMMENT, 'cl _ id' smallint (3) unsigned not null comment, 'title' varchar (100) COLLATE utf8_unicode_ci not null comment, 'details' text COLLATE utf8_unicode_ci not null comment, 'date' datetime not null comment, 'au _ id' smallint (6) unsigned not null comment, 'click' int (100) unsigned not null default '0' COMMENT, 'reco' int (100) unsigned not null default '0' COMMENT, primary key ('id'), KEY 'fk _ class' ('cl _ id'), CONSTRAINT 'fk _ class' foreign key ('cl _ id ') REFERENCES 'fl '('id'), KEY 'fk _ author' ('au _ id'), CONSTRAINT 'fk _ author 'foreign key ('au _ id ') REFERENCES 'author' ('id') ENGINE = InnoDB default charset = utf8 COLLATE = utf8_unicode_ci 2. create a Foreign Key after creating the Table: Alter Table 'ym' Add constraint' fk _ author 'Foreign Key ('au _ id') References 'author' ('id'); 3. view the Table structure: Show Create Table 'ym'; 4. CASCADE: can be added at the end (can be added separately or all): on update cascade (cascade update) on delete cascade (cascade delete) for example: alter table 'ym' ADD constraint' fk _ author 'foreign key ('au _ id') REFERENCES 'author' ('id') ON UPDATE CASCADE