学生表
Student(Sno,Sname,Sage,Ssex)学生表 Sno:学号 Sname:学生姓名 Sage:学生年龄 Ssex:学生性别
create table Student
(
Sno INT not null PRIMARY key,
Sname VARCHAR(20) not null,
Sage VARCHAR(20) not null,
(
Sno INT not null PRIMARY key,
Sname VARCHAR(20) not null,
Sage VARCHAR(20) not null,
Ssex VARCHAR(20) not null
);
课程表
Course(Cno,Cname,Tno)课程表 Cno:课程编号 Cname:课程名称 Tno:教师编号
create table Course(
Cno VARCHAR(20) not null PRIMARY key,
Cname VARCHAR(20) not null,
Tno VARCHAR(20) not null,
foreign key(Tno) references Teacher(Tno) on delete cascade on update cascade
);
Cno VARCHAR(20) not null PRIMARY key,
Cname VARCHAR(20) not null,
Tno VARCHAR(20) not null,
foreign key(Tno) references Teacher(Tno) on delete cascade on update cascade
);
成绩表
SC(Sno,Cno,score)成绩表 Sno:学号 Cno:课程编号 score:成绩
create table SC(
Sno int not null,
Cno VARCHAR(20) not null,
score VARCHAR(10) not null,
foreign key(Sno) references Student(Sno) on delete cascade on update cascade,
foreign key(Cno) references Course(Cno) on delete cascade on update cascade
);
教师表
Teacher(Tno,Tname)教师表 Tno:教师编号: Tname:教师名字
create table Teacher(
Tno VARCHAR(20) not null PRIMARY key,
Tname VARCHAR(20) not null
);
Tno VARCHAR(20) not null PRIMARY key,
Tname VARCHAR(20) not null
);