i have table foods having columns:
- food_id(pk)
- foodname
- fooddescription
- foodimage
- category_id(fk)
- res_id(fk)
and other table restaurant having columns:
- res_id(pk)
- resname
- food_id(fk)
- location
when try insert record of table gives error like:
getting “#1452 - cannot add or update child row: foreign key constraint fails ”
is structure of table correct?
my first guess (without knowing database using) 2 foreign keys set not null means foods record cannot created without restaurant record refer to, , restaurant record cannot created without food record refer to. try making them optional, or removing foreign keys, try add records. if works, can reinstate foreign keys afterwards using update table command (check reference guide database see syntax specifics).
Comments
Post a Comment