MySQL intermediary table error code 1005 (150) can't create foreign key -
i have 2 tables want join intermediary table many many relationship
the first table booking
create table booking ( bookingid int not null auto_increment, customerid int, runid int, startdate date, enddate date, datebookedon timestamp default current_timestamp, primary key (bookingid), index idx_start (startdate), index idx_end (enddate), foreign key (runid) references run(runid), foreign key (customerid) references customer(customerid));
the second dog
create table dog( dogid int(6) not null, dogname varchar(15), medicalid int (6), gender character(1) check(gender in ('m', 'f')), age int(2), breed varchar(15), size character (1) check(size in ('s', 'm', 'l')), primary key (dogid));
and intermediary table follows gives error 1005(150) there wrong foreign key bookingid. can't see problem. welcomed.
create table isbooked( bookingid int not null, dogid int not null, foreign key (dogid) references dog(dogid), foreign key (bookingid) references booking(bookingid));
Comments
Post a Comment