1

You have misunderstood the exact nature of FOREIGN KEYs. The field specified as a FOREIGN KEY has to exist in the table you are altering! I've put a correction of one issue into the fiddle here and pointed out some of your errors. I moved all of the table creation steps above the foreign key creation steps because that, in itself, can be a source of ...


1

You may disable FKs (SET FOREIGN_KEY_CHECKS=0;), delete record, then enable FKs back. But it is too unsafe - this setting affects to all. Less (slightly) unsafe is SET SESSION FOREIGN_KEY_CHECKS=0;. You may remove FK, delete record, then restore FK. fiddle. Pay attention - CONSTRAINT symbol is used. It is less unsafe. Or you may edit the record(s) which ...


Only top voted, non community-wiki answers of a minimum length are eligible