Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: add foreign constraint problem
01-16-2014, 10:54 PM #1
- Join Date
- Dec 2005
- Thanked 79 Times in 79 Posts
add foreign constraint problem
I manualy changed foregn key_name (as auto suggested by client) coz it was too long (mysql complaining)
SQL Error (1452): Cannot add or update a child row: a foreign key constraint fails (`test`.<result 2 when explaining filename '#sql-a6c_4'>, CONSTRAINT `FK_t_hosts` FOREIGN KEY (`id_master`) REFERENCES `t` (`id`) ON )
I have 2 tables master-detail, where some master data does not have anything in detail.
01-17-2014, 01:53 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,668 Times in 2,637 Posts
Its simply a violation.
You cannot change/add a record since its missing its required foreign relation. Create the foreign relation first, then create the child record.
Although if I understand your last sentence properly, than that indicates your constraints have been applied backwards and you are constraining the 1 side of the 1. . .n relation. You should be constraining the n side of the relation.PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');