My SQLtutorial
My SQLtutorial
# publisherID publisherName
1 1 Prentice Hall
2 2 Penguin
DESCRIBE Titles;
Error 1452:Cannot add or update a child row: a foreign key constraint fails
(`mdb_sr65/titles`, CONSTRAINT `titles_ibfk_1` FOREIGN KEY (`publisherID`)
REFERENCES `publishers` (`publisherID`))
Try deleting the primary key when there are child records
DELETE FROM Publishers;
Error 1451:Cannot delete or update a parent row: a foreign key constraint fails
(`mdb_sr65/titles`, CONSTRAINT `titles_ibfk_1` FOREIGN KEY (`publisherID`)
REFERENCES `publishers` (`publisherID`))
A well designed database with entity and referential integrity is designed to minimise
the GIGO effect:
GIGO: Garbage In = Garbage Out