系统需求分析:
随着互联网的发展,计算机的软硬件不断的更新迭代,这时计算机已经可以管理超大规模的数据,文件系统远远不能满足各种应用的需求,数据库使得数据实现了结构化存储,数据更容易被共享。数据库管理系统既便于数据的集中管理,控制冗余,提高数据的利用率和一致性,又利于应用程序的开发和维护。
随着高校学生人数越来越多,课程越来越丰富,学生多老师少,迫切需要一个数据库管理系统来管理、存取大量的信息,则建立一个学生毕业设计选题系统具有非常大的实际应用意义。我们知道计算机具有运算速度快,处理能力强等特点。因此,为了保证学校信息的流畅,工作高效,学生毕业设计选题系统应运而生。这不但能使教务人员从复杂的管理中解脱出来,而且对于推动教学的发展也起到非常重要的作用。
系统功能需求分析:
教师和学生进行双向选择,即学生可选择相应的毕业设计题目,教师也可选择学生。
1)教师:
1.1 教师可以增加毕业设计题目,人数,及要求。
1.2 教师可录取报名的学生,查看学生的详细信息如学生的基本信息等内容。
1.3针对不同的用户,可进行相关的统计、查询可查看报自己的学生人数,基本信息等。
2)学生:
2.1 可浏览教师的毕业设计题目及教师的简介等内容。
2.2 可查看自己的个人信息(基本信息)。
2.3 可以报毕业设计题目,每人限报两个,第一选题志愿和第二选题志愿。
3)管理员
3.1 可对每个教师、学生进行统计分析与维护。
2.概念设计(E-R图)根据需求分析结果,学生、教师、管理员、题目、班级、专业、学院等可建模为基本实体集。
各基本实体集的属性定义如下:
学生(Student)实体集。其属性有:学号(studentNo)、姓名(studentName)、性别(sex)、出生日期(birthday)、籍贯(native)、民族(nation)等。教师(Teacher)实体集。其属性有:教师编号(teacherNo)、姓名(teacherName)、性别(sex)、学位(degree)等。班级(Class)实体集。其属性有:班级编号(classNo)、班级名称(className)等。专业(Speciality)实体集。其属性有:专业编号(specialityNo)、专业名称(specialityName)等。学院(Institute)实体集。其属性有:学院编号(instituteNo)、学院名称(instituteName)等。题目(Title)实体集。其属性有:题目编号(titleNo)、题目名称(titleName)、要求(requirement)、人数(population)等。管理员(Manager)实体集。其属性有:工号(managerNo)、姓名(managerName)、性别(sex)、联系方式(phoneNum)。定义联系集及属性:
选题(SelectTitle)联系集:它是题目实体集与学生实体集的一对多联系集,其描述属性有:题目编号(titleNo)、学号(studentNo)、教师编号(teacherNo)、志愿(wish)、录取情况(admission)等。出题(SetTitle)联系集:它是教师实体集与题目实体集的一对多联系集,没有联系属性。指导(Guidance)联系集:它是教师实体集与学生实体集的一对多联系集,没有联系属性。包含(Include)联系集:它是班级实体集与学生实体集的一对多联系集,没有联系属性。拥有(Hold)联系集:它是专业实体集和班级实体集的一对多联系集,没有联系属性。属于(Belong)联系集:它是学院实体集与教师实体集的一对多联系集,没有联系属性。设置(Establish)联系集:它是学院实体集与专业实体集的一对多联系集,没有联系属性。权限设置:
(1)用户(User):账号(userNo)、登录密码(password)、姓名(userName)、身份(identity)等。
(下划线加粗代表主码,斜体加粗代表外码 )
(1)学生Student表:由学生关系实体集转化而来。
学生Student(studentNo,studentName,sex,birthday,native,nation,classNo);
(2)教师Teacher表:由教师实体集转化而来。
教师Teacher(teacherNo,teacherName,sex,degree,instituteNo);
(3)班级Class表:由班级实体集转化而来。
班级Class(classNo,className,specialityNo);
(4)专业Speciality表:由专业实体集转化而来。
专业Speciality(specialityNo,specialityName,instituteNo);
(5)学院Institute表:由学院实体集转化而来。
学院Institute(instituteNo,instituteName);
(6)题目Title表:由题目实体集转化而来。
题目Title(titleNo,titleName,requirement,population,teacherNo);
(7)管理员Manager实体集转化的关系模式。
管理员Manager(managerNo,managerName,sex,phoneNum);
(8)选题SelectTitle联系集转化的关系模式。
选题SelectTitle(titleNo,studentNo,teacherNo,wish,admission);
(9)用户User关系模式。
用户User(userNo,password,userName,identity);
(1)学生Student(studentNo,studentName,sex,birthday,native,nation,classNo);
分析Student关系模式得函数依赖关系为:
tudentNo->{studentName,sex,birthday,native,nation,classNo}
满足BCNF范式。
(2)教师Teacher(teacherNo,teacherName,sex,degree,instituteNo);
分析Teacher关系模式得函数依赖关系为:
teacherNo->{teacherName,sex,degree,instituteNo}
满足BCNF范式。
(3)班级Class(classNo,className,specialityNo)
分析Class关系模式得函数依赖关系为:
classNo->{className,specialityNo}
满足BCNF范式。
(4)专业Speciality(specialityNo,specialityName,instituteNo);
分析Speciality关系模式得函数依赖关系为:
specialityNo->{specialityName,instituteNo}
满足BCNF范式。
(5)学院Institute(instituteNo,instituteName);
分析Speciality关系模式得函数依赖关系为:
instituteNo->{instituteName}
满足BCNF范式。
(6)题目Title(titleNo,titleName,requirement,population,teacherNo);
分析Speciality关系模式得函数依赖关系为:
titleNo->{titleName,requirement,population,teacherNo}
满足BCNF范式。
5.表的设计(1)学生Student表(studentNo,studentName,sex,birthday,native,nation,classNo)
(2)教师Teacher表(teacherNo,teacherName,sex,degree,instituteNo)
(3)班级Class表(classNo,className,specialityNo);
(4)专业Speciality表(specialityNo,specialityName,instituteNo);
(5)学院Institute表(instituteNo,instituteName);
(6)题目Title表(titleNo,titleName,requirement,population,teacherNo);
(7)管理员Manager表(managerNo,managerName,sex,phoneNum);
(8)选题SelectTitle表(titleNo,studentNo,teacherNo,wish,admission);
(9)用户User表(userNo,password,userName,identity);
SET NAMES utf8mb4;SET FOREIGN_KEY_CHECKS = 0; -- ------------------------------ Table structure for class-- ----------------------------DROP TABLE IF EXISTS `class`;CREATE TABLE `class` ( `classNo` char(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '班级编号', `className` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '班级名称', `specialityNo` char(5) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '专业编号', PRIMARY KEY (`classNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ------------------------------ Table structure for institute-- ----------------------------DROP TABLE IF EXISTS `institute`;CREATE TABLE `institute` ( `instituteNo` char(3) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '学院编号', `instituteName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '学院名称', PRIMARY KEY (`instituteNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ------------------------------ Table structure for manager-- ----------------------------DROP TABLE IF EXISTS `manager`;CREATE TABLE `manager` ( `managerNo` char(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '管理员编号', `managerName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名', `sex` char(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别', `phoneNum` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系方式', PRIMARY KEY (`managerNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ------------------------------ Table structure for selecttitle-- ----------------------------DROP TABLE IF EXISTS `selecttitle`;CREATE TABLE `selecttitle` ( `titleNo` char(9) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '题目编号', `studentNo` char(12) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '学号', `teacherNo` char(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '教师编号', `wish` char(4) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '第一志愿/第二志愿', `admission` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '是/否', PRIMARY KEY (`titleNo`, `studentNo`, `teacherNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ------------------------------ Table structure for speciality-- ----------------------------DROP TABLE IF EXISTS `speciality`;CREATE TABLE `speciality` ( `specialityNo` char(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '专业编号', `specialityName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '专业名称', `instituteNo` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '学院编号', PRIMARY KEY (`specialityNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ------------------------------ Table structure for student-- ----------------------------DROP TABLE IF EXISTS `student`;CREATE TABLE `student` ( `studentNo` char(12) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '学号', `studentName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名', `sex` char(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别,男、女', `birthday` date NULL DEFAULT NULL COMMENT '出生日期', `native` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '籍贯', `nation` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '民族', `classNo` char(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '班级编号', PRIMARY KEY (`studentNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ------------------------------ Table structure for teacher-- ----------------------------DROP TABLE IF EXISTS `teacher`;CREATE TABLE `teacher` ( `teacherNo` char(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '教师编号', `teacherName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名', `sex` char(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别', `degree` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '学位', `instituteNo` char(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '学院编号', PRIMARY KEY (`teacherNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ------------------------------ Table structure for title-- ----------------------------DROP TABLE IF EXISTS `title`;CREATE TABLE `title` ( `titleNo` char(9) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '题目编号', `titleName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '题目名称', `requirement` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '要求', `population` int(11) NULL DEFAULT NULL COMMENT '人数', `teacherNo` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '教师编号', PRIMARY KEY (`titleNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ------------------------------ Table structure for user-- ----------------------------DROP TABLE IF EXISTS `user`;CREATE TABLE `user` ( `userNo` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账号', `password` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码', `userName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名称', `identity` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '身份:学生、教师、管理员', PRIMARY KEY (`userNo`) USING BTREE) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; SET FOREIGN_KEY_CHECKS = 1;
(1)查看某位学生的基本信息
SELECT * FROM student WHERe studentNo=’...’;
查看某位教师的基本信息
SELECt * FROM teacher WHERe teacherNo='...';
(2)学生浏览教师的毕业设计题目
SELECt * FROM title
(3)教师可录取报名的学生
UPDATe selecttitle SET admission='是'
WHERe studentNo='...' AND wish='...';
(4)教师更新题目信息
UPDATE title SET ... WHERe titleNo='...';
(5)教师查看每个题目的选题人数
SELECT titleNo,teacherNo,COUNT(DISTINCT studentNo)
FROM selecttitle GROUP BY titleNo HAVINg teacherNo='...';
(6)统计每位教师的出题数
SELECT teacherNo,COUNT(DISTINCT titleNO)FROM title GROUP BY teacherNo;
(7)教师删除某个题目信息(删除)
DELETe FROM title WHERe titleNo=’...’;
(8)删除已被录取的学生的另一个未录取的选题信息
DELETe FROM selecttitle WHERe admission='否' AND studentNo='...';
(9)教师查看报了自己题目的某个学生的信息
SELECT a.studentNo,studentName,sex,birthday,native,nation,classNo
FROM student a,selecttitle b
WHERe a.studentNo=b.studentNo AND b.studentNo='...';
(10)学生查看自己选题的教师的基本信息
SELECT b.teacherNo,teacherName,sex,degree,instituteName
FROM selecttitle a,teacher b,institute c
WHERe a.teacherNo=b.teacherNo AND b.instituteNo=c.instituteNo
AND a.teacherNo='...';
(11)查询学生所在班级,专业
SELECT studentNo,studentName,className,specialityName
FROM student a LEFT JOIN class b ON a.classNo=b.classNo
RIGHT JOIN speciality c ON b.specialityNo=c.specialityNo
WHERe studentNo='...';
(12)查询选了某个题目的学生的信息
SELECt studentNo,studentName,sex,classNo
FROM student
WHERe studentNo IN
(SELECt studentNo FROM selecttitle WHERe titleNo='...');