我想在 MySql 中使用 3 个复合键?这个可以吗?
create table lecturer(
lec_id varchar(6) not null,
lec_name varchar(18)
primary key(lec_id)
);
create table subject(
sub_code varchar(6) not null,
sub_name varchar(18)
primary key(sub_code)
);
create table lecDetails(
lec_id varchar(6) not null,
sub_code varchar(6) not null,
sem varchar(6) not null,
primary key(lec_id,sub_code,sem)
FOREIGN KEY (lec_id) REFERENCES lecturer(lec_id)
ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (sub_code) REFERENCES subject(sube_code)
ON UPDATE CASCADE ON DELETE CASCADE
);