landysaccount Posted October 31, 2009 Share Posted October 31, 2009 Hello. I'm trying to test something I read in a book but, I'm getting an error and can't figure out where is the mistake. I get error 105/1005 cant' create table survey_responses. Here's my sql script: create table survey_question( quest_id int(3) unsigned not null auto_increment, question varchar(80) not null, primary key( quest_id ) ) engine=innodb; /* Survey answers */ create table survey_anwers( ans_id int(3) unsigned not null auto_increment, quest_id int(3) unsigned not null, ans_text varchar(40) not null, primary key( ans_id ), foreign key( quest_id ) references survey_question( quest_id ) ) engine=innodb; /* Survey responses */ create table survey_responses( resp_id int(10) unsigned not null auto_increment, quest_id int(3) unsigned not null, ans_id int(3) unsigned not null, primary key ( resp_id ), foreign key( quest_id ) references survey_question( quest_id ), foreign key( ans_id ) references survey_answers( ans_id ) ) engine=innodb; Both foreign keys are of the same type and size... What am I doing wrong? Thanks in advanced for your help. Quote Link to comment https://forums.phpfreaks.com/topic/179741-solved-help-with-foreign-key-error-1005/ Share on other sites More sharing options...
landysaccount Posted October 31, 2009 Author Share Posted October 31, 2009 I read this post: http://www.phpfreaks.com/forums/index.php/topic,274744.0.html but, still can't find help. Even read the http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html and followed the suggestions but, still can't get it right. Quote Link to comment https://forums.phpfreaks.com/topic/179741-solved-help-with-foreign-key-error-1005/#findComment-948338 Share on other sites More sharing options...
landysaccount Posted October 31, 2009 Author Share Posted October 31, 2009 Solved the problem. Found out more information on the error by executing: SHOW ENGINE INNODB STATUS That guided me to notice that the table name survey_answer was misspelled so, there wasn't a match. How stupid that was. Quote Link to comment https://forums.phpfreaks.com/topic/179741-solved-help-with-foreign-key-error-1005/#findComment-948341 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.