Possible Duplicate:
Error appears in sql when trying to add multiple foreign keys
I am trying to alter a table so That I can add a foreign key constraint in mysql database:
ALTER TABLE `Question` ADD CONSTRAINT `FK_question` FOREIGN KEY (`QuestionId`)
REFERENCES `Image_Question` (`QuestionId`) ON DELETE CASCADE ;
Problem is that it is giving me this error:
1452 – Cannot add or update a child row: a foreign key constraint fails (
mobile_app.‘#sql-4517_15241’>, CONSTRAINT
FK_questionFOREIGN KEY
(QuestionId) REFERENCESImage_Question(QuestionId) ON DELETE
CASCADE)
What does this error actually mean and what are the possible solutions I might have to undertake in order to fix this?
Probably
Image_Question.QuestionIdis not unique. And it also looks like the FK should go the other way around, fromImage_QuestiontoQuestion