Hi guys,

I'm trying to add a FK on Media Table the parents table are Classes and Lessons tables.
And when I tried to add a Foreign Keys this is the error messages below.

First error message:
Code:
Error

SQL query:

ALTER TABLE  `media` ADD FOREIGN KEY (  `classid` ) REFERENCES  `myonliq6_warren`.`classes` (

`classid`
) ON DELETE CASCADE ON UPDATE CASCADE ;

MySQL said: Documentation

#1452 - Cannot add or update a child row: a foreign key constraint fails (`myonliq6_warren`.`#sql-5dc9_a0db8d`, CONSTRAINT `#sql-5dc9_a0db8d_ibfk_1` FOREIGN KEY (`classid`) REFERENCES `classes` (`classid`) ON DELETE CASCADE ON UPDATE CASCADE)
Second error message:
Code:
Error
SQL query:

ALTER TABLE  `media` ADD FOREIGN KEY (  `lessonid` ) REFERENCES  `myonliq6_warren`.`lessons` (

`lessonid`
) ON DELETE CASCADE ON UPDATE CASCADE ;

MySQL said: Documentation

#1452 - Cannot add or update a child row: a foreign key constraint fails (`myonliq6_warren`.`#sql-5dc9_a0db8d`, CONSTRAINT `#sql-5dc9_a0db8d_ibfk_1` FOREIGN KEY (`lessonid`) REFERENCES `lessons` (`lessonid`) ON DELETE CASCADE ON UPDATE CASCADE)
What could be the reason for this?

Thanks in advance.