22,299
社区成员




一、
(1)∏学号,姓名,课程名,分数(σ专业='英语'(学生) ∞ 学习 ∞ 课程)
(2)∏学号,姓名,专业,分数(σ分数>90(σ 专业='数据库原理'(学生) ∞ 学习))
(3)∏学号,姓名,专业(学生)-∏学号,姓名,专业(σ课程号='C135'(学习) ∞ 学生)
(4)∏学号,姓名,专业(学生)-∏学号,姓名,专业(σ分数<60(学习) ∞ 学生)
(5)select 学号,姓名,专业 from 学生 where 学号 not in (select 学号 from 学习 where 课程号='C135')
(6)select 学号,姓名,专业 from 学生
where 学号 in(select 学号 from 学习 where 课程号='C135'
and exists(select 1 from 学习 where 课程号='C219'))
(7)delete from 学生 where 学号 in(select 学号 from 学习 where 分数=0)
(8)create view AAA as
select s.学号,姓名,c.课程号,分数 from 学生 s,学习 sc,课程 c
where s.学号=sc.学号 and c.课程号=sc.课程号 and c.名称='英语'
二、
(1)select * from emp where tel is not null
(2)select * from emp where sal between 500 and 800
(3)select empno,ename,age,sal from emp order by age
(4)select sal_avg=avg(sal) from emp where deptno='D_01'
(5)select ename from emp where deptno='D_01' and age>40 and sal<400
三、
(1) 不满足2NF。原因:C、D均部分函数依赖于码
(2) 关系模式R2的码为B#,R2中存在 B#->C,C->D 传递函数依赖,所以关系模式R2最高满足2NF。
四、
(1)select SNO from SPJ where JNO='J1'
(2)select SNO from SPJ where JNO='J1' and PNO='P1'
(3)select SNO from SPJ,P where JNO='J1' and SPJ.PNO=P.PNO and COLOR='红色'
(4)select SNO from SPJ where SNO not in (select SNO from SPJ,P,S
where SPJ.PNO=P.PNO and S.SNO=SPJ.SNO and COLOR='红色' and ADDRESS='天津')
(5)select JNO from (select JNO,PNO from SPJ
where PNO in (select PNO from SPJ where SNO='S1'))t
group by JNO having count(PNO)=(select count(PNO) from SPJ where SNO='S1')