Jump to content

[SOLVED] Help with foreign key error 1005


landysaccount

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.