create table student(
sno char(10) primary key comment '学号',
sname varchar(20) not null unique comment '姓名',
sex enum('男','女') default '男' comment '性别',
birthday Date comment '出生日期',
classno char(10) not null comment '班级代码',
tel char(11) default '不详' comment '电话号码' check(len(tel)=11),
address varchar(50) comment '家庭住址',
phone blob comment '照片'
);
create table class(
classno char(10) primary key comment '班号',
classname varchar(10) not null comment '班级名',
pno char(4) not null comment '专业代码',
num int comment '班级人数' check(num>=0)
);
create table course(
classno char(10) comment '课堂号' primary key,
cname varchar(30) comment '课程号' not null,
credits tinyint comment '学分' check(credits>0)
);
create table result(
sno char(10) comment '学号',
cno char(7) comment '课号',
result decimal(3,1) not null comment '分数' check(result<=100 and result>=0)
);
alter table result
add constraint pk_sno_cno primary key (sno,cno);
create table professional(
pno char(4) comment '专业代码' primary key,
pname varchar(30) comment '专业名称' not null,
deptno char(2) comment '系部代码' not null
);
create table department(
deptno char(2) comment '系部代码' primary key,
dempname varchar(20) not null comment '系部名称'
);