(3)学生已修学分统计 SQL语句是:
create view 学生已修学分信息(学号,姓名,已修学分) as
select A.Sno_hx,A.Sname_hx,sum(C.Ccredit_hx) from Students_Hx A,Study_Hx B,Courses_Hx C where A.Sno_hx=B.Sno_hx and B.Cno_hx=C.Cno_hx group by A.Sno_hx,A.Sname_hx
SQL执行结果为:
(4)班级学生各课程平均成绩 SQL语句:
create view 班级学生各课程平均成绩(班级,专业,课程,学分,平均成绩) as
select
A.CLname,B.Mname_hx,C.Cname_hx,C.Ccredit_hx,avg(D.STgrade_hx) '班级平均成绩'
from Class_hx A,Major_Hx B,Courses_Hx C,Study_Hx D,Students_Hx E,Setup_Hx F where
A.CLno_hx=E.CLno_hx
and
A.Mno_hx=B.Mno_hx
and
A.CLno_hx=F.CLno_hx and
F.Cno_hx=C.Cno_hx and D.Sno_hx=E.Sno_hx and C.Cno_hx=D.Cno_hx group by A.CLname ,B.Mname_hx,Cname_hx,C.Ccredit_hx 执行结果:
5.4 索引的建立
因为每一个表建立,SSMS会自动生成一个聚集索引,所以不需要再手动建立聚集索引。
(1)教师编号
create index Teacher on Teachers_Hx(Tno_Hx) 执行结果如下:
(2)学生学号
create index Student on Students_Hx(Sno_hx) 执行结果:
(3)课程编号
create index Course on Courses_Hx(Cno_hx) 执行结果:
(4)班级编号
create index Class on Class_Hx(CLno_hx)