This seems to be a very common problem but I can’t seem to find an answer despite of all the posts and pseudotutorials I have read in the last 2 days :/
The project I am currently working on forces me to learn how to use MySQL and I seem to have run into a problem concerning ForeignKeys or Indexes.
I have these creates:
http://paste.ubuntu.com/1503473/
Edit: Inserting crutial part here cause the link above might die sometime:
CREATE TABLE user_book (
userid Varbinary(16),
bookid Varbinary(16),
PRIMARY KEY(userid, bookid),
INDEX(userid),
FOREIGN KEY(userid) REFERENCES user,
INDEX (bookid),
FOREIGN KEY(bookid) REFERENCES book
)ENGINE=INNODB;
Made the same mistake at user_chapter.
But sql throws an error at Table “user_book”:
#1005 – Can’t create table ‘mangressdb.user_book’ (errno: 150)
It would be really great if you could help me out here as I am close to crying. It is probably just a very stupid mistake on my part but I can’t find it.
Looks like you are getting name conflicts in your DDL. Try explicitly specifying the parent table columns to be used for the foreign keys:
You will need to also explicitly specify the parent column names for your
user_chaptertable.