SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    May 2011
    Posts
    242
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    #1452 - Cannot add or update a child row

    Good day,

    I have created a MySQL database wuth the following tables and relationships:
    http://www.libromania.cl/dsstgo/modelv7.jpg

    Using "load data local infile" instructions, I have loaded data in Schools, Classes and Books.
    When try to do it for Lists table, the following error message is generated:

    #1452 - Cannot add or update a child row: a foreign key constraint fails (`libroman_2012`.`Lists`, CONSTRAINT `Lists_ibfk_1` FOREIGN KEY (`ClassID`) REFERENCES `Classes` (`ClassID`))

    Any help would be very appreciated.

    Thanks a lot.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,272
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    the message means that one of the rows you're loading into the lists table has a value in the ClassID column that isn't in the classes table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict
    Join Date
    May 2011
    Posts
    242
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi r937,

    Here is the file I intended to load into Lists table:
    http://www.libromania.cl/dsstgo/dsstgo_lists.txt

    And the classes table is:
    http://www.libromania.cl/dsstgo/dsstgo_classes.txt

    I see there is classes with identifiers from i to 73 in both files.

    Thanks a lot!!!

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,272
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    how do i know which columns are supposed to reference which columns?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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