--表tb_user
create table tb_user (
id int not null,
username varchar(32) not null
);
--給tb_user新增主鍵
alter table tb_user add constraint pk_users primary key (id);
--表tb_course
create table tb_course (
id int not null primary key,
name varchar(20) not null
--表tb_mark
create table tb_mark (
uid int not null,
cid int not null,
mark int not null,
primary key (uid, cid)
--給tb_mark新增外來鍵
alter table tb_mark add constraint fk_uid foreign key(uid) references tb_user(id);
alter table tb_mark add constraint fk_cid foreign key(cid) references tb_course(id);
--表tb_user
create table tb_user (
id int not null,
username varchar(32) not null
);
--給tb_user新增主鍵
alter table tb_user add constraint pk_users primary key (id);
--表tb_course
create table tb_course (
id int not null primary key,
name varchar(20) not null
);
--表tb_mark
create table tb_mark (
uid int not null,
cid int not null,
mark int not null,
primary key (uid, cid)
);
--給tb_mark新增外來鍵
alter table tb_mark add constraint fk_uid foreign key(uid) references tb_user(id);
alter table tb_mark add constraint fk_cid foreign key(cid) references tb_course(id);