无法添加外键约束,mysql

时间:2017-02-19 17:11:33

标签: mysql sql

我有三个表:倡导者,客户和事件。在事件表中,我有两个字段引用了两个来自主表和一个字段引用客户端的字段,当我尝试添加外键时,我得到这个不能添加外键约束错误。

create table advocate(

ida int(11) not null, 
idk int(11) not null,

#...

primary key(ida, idk)

)engine = InnoDB default charset=utf8;



create table client(

jmb varchar(13) not null primary key

#...

)engine=InnoDB default charset=utf8;



create table event(

ida int(11) not null,
idk int(11) not null,
jmb varchar(13) not null,

#...

primary key(ida,idk,jmb),

foreign key(ida, idk)
references advocate(ida, idk)
on update cascade
on delete restrict,

foreign key(jmb)
references client.jmb
on update cascade
on delete restrict


)engine=InnoDB default charset=utf8;

1 个答案:

答案 0 :(得分:1)

你可以尝试改变:

def function(object, a):
    if name in object.__dict__:
        setattr(object, a, 5)

__dict__