如果需要代码请评论区留言或私信
课程设计具体实现
数据库设计
E-R图
关系模式
- 教师(工号,姓名,学院) 主键(工号)
- 学生(学号,姓名,性别,年龄,班级,专业,学分) 主键(学号)
- 课程(课程编号,教师编号,课程名称,课程学分) 主键(课程编号) 外键(教师编号)
- 选课(学号,课程编号,分数) 主键(学号,课程编号) 外键(学号,课程编号)
表的结构
create table Adminuser(username int unsigned primary key not null auto_increment,password varchar(16) default '123456'
);
create table Studentuser(username int unsigned primary key not null auto_increment,password varchar(16) default '123456'
);
create table teacheruser(username int unsigned primary key not null auto_increment,password varchar(16) default '123456'
);create table teacher(job_num int unsigned primary key auto_increment,t_name varchar(20) not null,college varchar(20) not null
);
create table student(stu_num int unsigned primary key auto_increment,stu_name varchar(20) not null,sex varchar(1) not null,age tinyint unsigned not null,class varchar(20) not null,major varchar(20) not null,credit int(5) unsigned not null default 0
);
create table course(c_num int unsigned primary key auto_increment,t_num int unsigned not null,c_name varchar(20) not null,c_credit tinyint unsigned not null,constraint c_t_num foreign key(t_num) references teacher(job_num)
);
create table select_course(stu_num int unsigned ,c_num int unsigned not null,s_score float(5,2) not null,primary key(stu_num,c_num),foreign key(stu_num) references student(stu_num),foreign key(c_num) references course(c_num)
);
函数和存储过程
delimiter $
CREATE PROCEDURE passnumber(in c_id int unsigned)begin
select sum(case when s_score>=60 then 1 else 0 end) as 及格人数,
sum(case when s_score<60 then 1 else 0 end) as 不及格人数
from score where c_num=c_id;end $
delimiter ;
用例图
类图
界面截图