create table buys (
user_id INT(11) not null,
software_id INT(11) not null,
associated_id INT(11) not null,
primary key (associated_id),
foreign key (software_id) references software,
foreign key (user_id) references users,
foreign key (associated_id) references associated);
我有一个三元关系关联表,具有完全参与和键约束但不能添加外键约束
答案 0 :(得分:0)
检查以下查询:
CREATE TABLE products(
prd_id int not null auto_increment primary key,
cat_id int not null,
FOREIGN KEY fk_cat(cat_id)
REFERENCES categories(cat_id)
)ENGINE=InnoDB;
在你的情况下:
foreign key (software_id) references software -> here column name is missing in software table