学生成绩管理系统 数据库设计(内含sql查询语句)[研究分析].doc
属于年龄性别学 生1课程号学号选课课程名课 程mn 姓名学时 N1ISAN4学分开课学期班号班 级 1选修课必修课开设专 业编号专 业 属于 N2系名称系编号1 1 N3 开设专业名 系1create database 学生成绩管理系统gouse 学生成绩管理系统gocreate table 系( 系编号 char(15) NOT NULL UNIQUE, 系名称 char(20) NOT NULL UNIQUE, constraint 系pk primary key(系编号,系名称)create table 专业( 专业编号 char(15) NOT NULL UNIQUE, 专业名 char(20) NOT NULL UNIQUE, 系编号 char(15) NOT NULL, constraint 专业pk primary key(专业编号,专业名), constraint FK_系_专业 foreign key(系编号) references 系(系编号)create table 班级( 班号 char(15) NOT NULL UNIQUE, 班名 char(20) NOT NULL UNIQUE, 专业编号 char(15) NOT NULL, constraint 班级pk primary key(班号,班名), constraint FK_专业_班级 foreign key(专业编号) references 专业(专业编号)create table 学生( 学号 char(15) NOT NULL UNIQUE, 姓名 char(20) NOT NULL, 性别 char(5), 年龄 int, 班号 char(15), constraint 学生pk primary key(学号), constraint 性别ck check(性别=男 or 性别=女), constraint 年龄ck check(年龄>0 and 年龄<90), constraint FK_班级_学生 foreign key(班号) references 班级(班号)create table 课程( 课程号 char(15) NOT NULL UNIQUE, 课程名 char(20) NOT NULL, 学时 int, 学分 float, 开课学期 char(20), 课程性质 char(10), constraint 课程pk primary key(课程号), constraint 课程性质ck check(课程性质=选修 or 课程性质=必修)create table 选课( 学号 char(15) NOT NULL, 课程号 char(15) NOT NULL, 成绩 float, constraint 选课pk primary key(学号,课程号), constraint 成绩ck check(成绩>=0 and 成绩<=100), constraint FK_学生_选课 foreign key(学号) references 学生(学号), constraint FK_课程_选课 foreign key(课程号) references 课程(课程号)create view 学生成绩(学号,姓名,班级,课程名,成绩,学分绩点) AS select 选课.学号,姓名,班级=(select 班名 from 班级 where 班号=( select 班号 from 学生 where 学生.学号=选课.学号), 课程名,成绩,学分绩点= case when 成绩>=90 then 学分*4 when 成绩<90 and 成绩>=85 then 学分*3.5 when 成绩<85 and 成绩>=80 then 学分*3 when 成绩<80 and 成绩>=75 then 学分*2.5 when 成绩<75 and 成绩>=70 then 学分*2 when 成绩<70 and 成绩>=65 then 学分*1.5 when 成绩<65 and 成绩>=60 then 学分*1 when 成绩<60then 学分*0 end from 学生,课程,选课 where 学生.学号=选课.学号 and 课程.课程号=选课.课程号3技术l类别