I have the following parent table:
create table A(
a int(64) unsigned not null,
b set('a', 'b', 'c') not null default '',
c set('d', 'e') not null default '',
primary key ( a,b,c)
)
And child:
create table B(
d int(64) unsigned not null auto_increment,
a int(64) unsigned not null,
c set('d', 'e') not null default '',
primary key (d),
key fk1 (a,c),
constraint fk1 foreign key (a, c) references (a, c)
)
But then I get an fk error on creating the child table in mysql logs:
Error in foreign key constraint of table Foreign key (a,c) references A (a,c): Cannot find an index in the referenced table where the referenced columns appear as the first columns, or column types in the table and the referenced table do not match for constraint.
What is incorrect with my SQL?