14 .R×S表示R与S的________。
15 .设有学生关系:S(XH,XM,XB,NL,DP)。在这个关系中,XH表示学号,XM表示姓名,XB表示性别,NL表示年龄,DP表示系部。查询学生姓名和所在系的投影操作的关系运算式是________________。 (问答题) 16 .在“学生-选课-课程”数据库中的3个关系如下:S(S#,SNAME,SEX,AGE);SC(S#,C#,GRADE); C(C#,CNAME,TEACHER),查找选修“数据库技术”这门课程学生的学生名和成绩,若用关系代数表达式来表示为________________。 (问答题) 17 .已知系(系编号,系名称,系主任,电话,地点)和学生(学号,姓名,性别,入学日期,专业,系编号)两个关系,系关系的主码是________,系关系的外码是________,学生关系的主码是________,学生关系的外码是________。 (问答题)
五、综合题
1.对下列关系模式分别用关系代数、元组关系演算和SQL实现下列查询: ⑴查询学生95001的所有信息 select * from Student
where Sno=’95001’
⑵查询学生95001的姓名和所在系
select Sname,Sdept from Student
where Sno=’95001’
⑶查询选修了1号课的学生的学号 select Sno from SC
where Cno=’1’
⑷查询选修了1号课的学生的姓名 select Sname
from Student,SC
where Student.Sno=SC.Sno and Cno=’1’
⑸查询至少选修了1号课和3号课的学生的学号
select Sno
from SC X , SC Y
where X.Sno=Y.Sno and X.Cno=’1’ and Y.Cno=’3’
⑹查询至少选修了一门其直接先行课为5号课的学生学号 select *
from SC,Course
where Course.Cno=SC.Cno and Cpno=’5’
⑺查询没有选修1号课程的学生姓名 select Sname
from Student ,SC where not exists (select * from SC
where SC.Sno=Student.Sno and SC.Cno=’1’) ⑻查询选修了全部课程的学生的学号和姓名
select Sno,Sname from Student where not exists (select * from Course
where not exists (select * from SC
where SC.Sno=Student.Sno and SC.Cno=C.Cno)) )
⑼查询最少选修了95002学生所选课程的学生学号 select Sno from SC X
where not exists (select * from SC Y
where Sno=’95002’ and not exists (select * from SC Z
where Z.Sno=X.Sno and Z.Cno=Y.Cno)) )
⑽查询每门课的平均成绩(只要求SQL) select Cno,avg(Grade) from SC
group by Sno
(11)查询每个学生的平均成绩(只要求SQL) select Sno,avg(Grade) from SC
group by Sno
2.对学生-课程数据库有如下查询:select Cname from Student,Course,SC where Student.Sno=SC.Sno and SC.Cno=Course.Cno and Student.Sdept=’IS’,试画出用关系代数表示的语法树,并进行优化,画出优化后的标准语法树。