Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Thanked 78 Times in 78 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 )
    What does this mean ?

    I have 2 tables master-detail, where some master data does not have anything in detail.
    Last edited by BubikolRamios; 01-17-2014 at 02:01 AM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 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'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts