# 1452 - always add or update a child row: a foreign key constraint fails (` HXCMS -- cloud `. ` user_info `, constraint ` fk_user_info_user1 ` foreign key (` user_id `) REFERENCES ` user ` (` id `) ON DELETE NO ACTION ON the update NO ACTION)
Hope and correct
CodePudding user response:
First of all, I'm here to throw cold water on, I don't recommend to do foreign key constraints in the database level, maintain foreign key relationship advice at the code level,The reasons are the following:
1. The foreign key constraint is a comparative performance of operation, when you add, modify, will produce extra consumption
2. Easier to insert mistakes, such as data deletion, foreign key constraints will not let you enough, of course, the production environment is not recommended for physical delete,
Recently on the individual number WeChat public "andyqian", a series of articles on the MySQL updated, has said the index, table structure design, hope to be able to help you,
CodePudding user response:
The original poster and see if it is the foreign key data is not in the main table