SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast ParfaitMacaron's Avatar
    Join Date
    Mar 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    phpMyAdmin #1005 errno: 150 error code

    I am trying to import MySQL code into phpMyAdmin.

    #1005 - Can't create table 'dbname.test_table' (errno: 15
    The above is the error code which I am getting. I have googled and it suggests it's a foreign key constraint error.

    I am reading this article, trying to troubleshoot. http://verysimple.com/2006/10/22/mys...frm-errno-150/

    - All tables use INNODB engine.
    - I have re-ordered my tables (it has created the first few tables which require no foreign keys successfully)

    Is it wrong to have a foreign key in my members type table called memberID and also to have the primary key in my members table called memberID. Could this be why it is not importing when I list the constraint like this...

    Code:
    CONSTRAINT member_fk FOREIGN KEY (`member_id`) REFERENCES members (`member_id`)
    Thank you.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by ParfaitMacaron View Post
    Is it wrong to have a foreign key in my members type table called memberID and also to have the primary key in my members table called memberID.
    yes, it is wrong, you have it backwards

    member types to members is a one-to-many relationship

    each member type can have multiple members, but a member can belong to only one member type

    in one-to-many relationships, the foreign key goes in the "many" table, referencing the primary key of the "one" table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast ParfaitMacaron's Avatar
    Join Date
    Mar 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    yes, it is wrong, you have it backwards

    member types to members is a one-to-many relationship

    each member type can have multiple members, but a member can belong to only one member type

    in one-to-many relationships, the foreign key goes in the "many" table, referencing the primary key of the "one" table
    Thanks for your reply!

    I've checked my relationships according to how you mentioned above and it is how you have described. What I've done is import tables (successful) without constraints. I am going to try and use ALTER table now and see if I can implement the constraints that way since the tables with fields are there now.


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
  •