作业要求:
作业答案
create table class(
cid int primary key auto_increment,
caption char(10));
create table teacher(
tid int primary key auto_increment,
tname char(10));
create table student(
sid int primary key auto_increment,
sname char(10),
gender enum('female','male') default'male',
class_id int,
foreign key(class_id) references class(cid)
on update cascade
on delete cascade);
create table course(
cid int primary key auto_increment,
cname char(10),
teacher_id int,
foreign key(teacher_id) references teacher(tid)
on update cascade
on delete cascade);
create table score(
sid int primary key auto_increment,
student_id int,
foreign key(student_id) references student(sid)
on update cascade
on delete cascade,
course_id int,
foreign key(course_id) references course(cid)
on update cascade
on delete cascade);