Handling database integrity
问题 I'm introducing database integrity using innodb constraints in the next version of my application. Everything goes well, but some of my tables have records with deleted references (dead records) and because of them I can't add constraints to the table. I am trying: ALTER TABLE `article` ADD FOREIGN KEY (`author_id`) REFERENCES `authors` (`id`) ON DELETE CASCADE; And I get: #1452 - Cannot add or update a child row: a foreign key constraint fails (`books`.<result 2 when explaining filename '