1、数据库课程设计 教学管理系统 作者: 日期:2 个人收集整理 勿做商业用途学校教务管理的数据库设计学生表drop table studentcreate table student (Sno char(40) primary key, Sname char(40), Ssex char(2), Sclass char(20), Sclassno char(20), Sbirthday datetime, Shome char(40), Sdept char(40), );insert into student values (12232617,Victor ,男,英语,082,2/1/1990
2、,America,07);insert into student values (12232621,Susan,女,英语,083,1/25/1990,japan,07);insert into student values (12232625,Carlos,男,广告设计,082,2/12/1990,America,01);insert into student values (12232627,Dave,男,电子商务,082,10/1/1989,America,02);insert into student values (12232628,Gaby,女,金融,081,1/12/1990,It
3、aly,04);insert into student values (12232629,Lynette,女,会计,082,9/12/1989,Britain,05);insert into student values (12232636,Bree,女,会计,082,11/18/1989,Italy,05);insert into student values (12232645,tom,男,数学,081,12/22/1989,Britain,06);insert into student values (12232631,zach,男,国际贸易,081,4/16/1990,Japan,03
4、);insert into student values (12232641,Karl,男,计算机,082,6/8/1990,Britain,08);insert into student values (12232633,Edie,女,广告设计,083,12/11/1989,Holland,01);insert into student values (12232643,Dylan,女,数学,082,4/20/1990,Britain,06);insert into student values (12232610,John,男,金融,081,11/25/1989,America,04);i
5、nsert into student values (12232620,Mike,男,计算机,082,12/30/1989,China,08);系表drop table departmentcreate table department (Sdept char(40)primary key, Dname char(9), Dmaster char(20)); insertinto department values (01,广告设计,zt);insertinto department values (02,电子商务,bc);insertinto department values (03,国际
6、贸易,kl);insertinto department values (04,金融,nn);insertinto department values (05,会计,jr);insertinto department values (06,数学,ed);insertinto department values (07,英语,mj);insertinto department values (08,计算机,ry); 教师表drop table teachercreate table teacher (Tno char(9)primary key, Tname char(20), Tclass c
7、har(20), Twork char(20);insert into teacher values (001,赵老师,特级教师,线性代数);insert into teacher values (002,钱老师,教授,解析几何);insert into teacher values (003,孙老师,教授,金融);insert into teacher values (004,李老师,高级教师,数据库);insert into teacher values (005,彭老师,高级教师,课程设计);insert into teacher values (006,贾老师,高级教师,会计);ins
8、ert into teacher values (007,尤老师,高级教师,计算机);insert into teacher values (008,耿老师,教授,英语);课程表drop table coursecreate table course (Cno char(4) primary key, Cname char(40), Ccredit smallint); alter table course add sort char (10);insertinto course values (0001,线性代数,3,必修);insertinto course values (0002,二外
9、日语,4,修);insertinto course values (0003,数据库,2,必修);insertinto course values (0004,第三方物流,2,选修);insertinto course values (0005,大学英语,4,必修);insertinto course values (0006,课程设计,2,任选);项目表drop table projectcreate table project (Pno char(9)primary key, Pname char(20), Pman char(20));insert into project values
10、 (07,project1,cici)insert into project values (08,project2,gigi)insert into project values (09,project3,coco)insert into project values (10,project4,june)选课表drop table sccreate table sc (Sno char(9), Cno char(4), Grade smallint, primary key (Sno,Cno), );insert into sc values (12232617,0001,85);inser
11、t into sc values (12232617,0002,68); insert into sc values (12232617,0003,96);insert into sc values (12232621,0005,81);insert into sc values (12232621,0001,92);insert into sc values (12232621,0002,92);insert into sc values (12232621,0003,92);insert into sc values (12232625,0005,92);insert into sc va
12、lues (12232625,0004,92);insert into sc values (12232625,0001,78);insert into sc values (12232625,0002,78);insert into sc values (12232627,0003,78);insert into sc values (12232627,0005,78);insert into sc values (12232627,0004,78);insert into sc values (12232627,0006,78);insert into sc values (1223262
13、8,0001,61);insert into sc values (12232628,0002,61);insert into sc values (12232628,0003,61);insert into sc values (12232628,0005,61);insert into sc values (12232629,0004,61);insert into sc values (12232629,0006,61);insert into sc values (12232629,0001,85);insert into sc values (12232629,0002,85);in
14、sert into sc values (12232636,0003,85);insert into sc values (12232636,0005,85);insert into sc values (12232636,0006,85);insert into sc values (12232636,0003,65);insert into sc values (12232645,0005,65);insert into sc values (12232645,0001,65);insert into sc values (12232645,0002,65);insert into sc
15、values (12232645,0005,90);insert into sc values (12232631,0003,90);insert into sc values (12232631,0001,90);insert into sc values (12232631,0004,90);insert into sc values (12232631,0002,90);insert into sc values (12232641,0001,80);insert into sc values (12232641,0002,80);insert into sc values (12232
16、641,0003,80);insert into sc values (12232641,0005,80);insert into sc values (12232633,0004,80);insert into sc values (12232633,0006,80);insert into sc values (12232633,0002,82);insert into sc values (12232633,0001,82);insert into sc values (12232637,0003,82);insert into sc values (12232637,0005,82);
17、insert into sc values (12232637,0006,82);insert into sc values (12232637,0001,79);insert into sc values (12232643,0002,79);insert into sc values (12232643,0003,79);insert into sc values (12232643,0005,79);insert into sc values (12232643,0004,79);insert into sc values (12232610,0001,83);insert into s
18、c values (12232610,0003,83);insert into sc values (12232610,0002,83);insert into sc values (12232610,0005,83);insert into sc values (12232620,0006,83);insert into sc values (12232620,0004,79);insert into sc values (12232620,0005,62);insert into sc values (12232620,0002,83);所有来自china的男生select Snamefr
19、ome studentwhere Shome=chinaand Ssex=男;所有0005号课程成绩90的同学select Snamefrom student,scwhere student。Sno=sc.Sno and sc.Cno=0005 and sc。Grade90教授课程设计的老师select Tnamefrom teacherwhere Twork=课程设计某班年龄最大的2名同学select Top 2from studentwhere Sclass =会计AND Sclassno=082order by Sbirthday asc;1989年以后出生的女同学select Snam
20、efrom studentwhere Sbirthday1/1/1989 and Ssex=女选修0004课程的学生及其成绩select Sname,Gradefrom student,scwhere student.Sno=sc.sno and Cno=0004没有授课的教师select Tnamefrom teacherwhere Twork= 某学生所选课程的总学分select sum(Ccredit)from sc ,coursewhere Sno=12232620 and sc。cno=course。cno 电子商务学生所学的所有课程select distinct course.Cn
21、amefrom student,course,sc,departmentwhere student。Sno=sc.Sno and o=o and student。Sdept=department。Sdept and Dname=电子商务按总学分找出某系学习最好的2名同学select top 5 Sname,sum(Ccredit)from student,sc,course,departmentwhere student.Sno=sc.Sno and course.Cno=sc。Cno and student.Sdept=department.Sdept and Dname=金融 group
22、by student.Sname按总学分积找出某系学习最好的5名同学select top 5 Sname,sum((Grade-50)/10*Ccredit)from student,sc,course,departmentwhere student。Sno=sc。Sno and course。Cno=sc.Cno and student。Sdept=department.Sdept and Dname=会计 group by student.Sname教授12232620学生必修课程的老师情况select Tno,Tname,teacher。Tclass,Tworkfrom student,sc,course,teacherwhere student.Sno=12232610 and teacher.Twork=course.Cname and course。Cno=sc.Cno12232610选修了那些系的课程select DISTINCT Dnamefrom sc,teacher,departmentwhere sc。cno in (select cno from sc where sno=12232610)数据库心得