《数据库原理与应用课后答案》由会员分享,可在线阅读,更多相关《数据库原理与应用课后答案(10页珍藏版)》请在金锄头文库上搜索。
1、以下答案如有问题,可当面讨论。第一章习题答案一、选择题1、A 2、 C 3、C 4、C 5、B 6、D 7、A 8、C二、填空题1、数据2、人工管理、文件系统、数据库3、结构化4、安全性、完整性、恢复功能5、能比较真实地模拟现实世界、容易为人所理解、便于在计算机上实现6、记录7、数据结构、数据操作、约束条件8、外模式、内模式、模式第二章 习题答案一、选择题1、B 2、A 3、D 4、不用做 5、B 6、D 7、B 8、D 9、C 10、C二、填空题1、关系数据结构、关系操作集合、关系完整性约束2、选择、投影、连接、除3、实体完整性、参照完整性、用户定义完整性4、域5、候选码6、属性集,度7、相
2、同、不同8、相同于9、关系、关系10、班级号四、综合题1、最小元组数 最大元组数0 1501 250 1510 253、(1)sno( pno=p1(SPJ)(2)sname( pno=p1(SPJ) S)(3)sno( pno=p1JNO= J1 (SPJ)(4)sno( color=红 (P) JNO=J1 (SPJ)(5)sname(color= 红(P) SPJ S)(6)Jno,PNO(SPJ) pno(sno=s1(SPJ)第三章 习题答案一、选择题1、B 2、B 3、C 4、D 5、B 6、B 7、A 8、D 9、C 10、B二、填充题1、一个或几个表、定义、数据 2、 (1)s
3、elect * from R union select * from T(2)select * from R where DWH=100 (3)select XM,XB from R(4)select XM,DWH from R where XB=女(5)select * from R,S where R.DWH=S.DWH(6)select XM,XB,DWM from R,S where XB=男 and R.DWH=S.DWH3、 (1)Insert Into R values(25,李明, 男 ,21, 95031)(2)Insert Into R(NUM,NAME,CLASS)val
4、ues(30, 郑和 ,95031)(3)update R set NAME=王华 where NUM=10(4)update R set CLASS=95091 where CLASS=95101(5)delete from R where NUM=20(6)delete from R where NAME like 王%四、综合题(数据库为 IQS_bak)(1)select * from suppliers(2)select partno,description,qonhand from inventory(3)select Q.partno,description,price,qono
5、rder from quotations Q,inventory I where suppno=02101 and Q.partno=I.partno(4)select partno, description from inventory where qonhand between 80 and 200 and unit=米(5)select partno, description ,price from inventory I , quotations QWhere I.partno=Q.partno Group by partno, description ,priceOrder by p
6、rice(6)select partno,description,avg(price) from inventory I , quotations QWhere I.partno=Q.partnoGroup by partno(7)select partno,price*qonorder from quotations Q where suppno=57101(8)select partno,sum(qonorder )from quotations group by partno order by partno(9)select NVENTORY.PARTNO,SUPPNO,PRICE,QO
7、NORDER,DELIVERY_TIME,QONHANDfrom QUOTATIONS,INVENTORYWHERE QUOTATIONS.PARTNO=INVENTORY.PARTNO (10)SELECT QUOTATIONS.PARTNO,PRICE FROM QUOTATIONS,SUPPLIERSWHERE NAME=缪向明 and QUOTATIONS.SUPPNO=SUPPLIERS.SUPPNO(11)SELECT QUOTATIONS.PARTNO,PRICE,DESCRIPTION,UNIT,QONHAND FROM QUOTATIONS,SUPPLIERS,INVENTO
8、RYWHERE NAME=缪向明 and QUOTATIONS.SUPPNO=SUPPLIERS.SUPPNOand QUOTATIONS.PARTNO=INVENTORY.PARTNO(12)SELECT SUPPLIERS.SUPPNO,NAME,ADDRESSFROM QUOTATIONS,SUPPLIERS WHERE QUOTATIONS.SUPPNO=SUPPLIERS.SUPPNO AND PARTNO=CZ02(13)SELECT PARTNO FROM QUOTATIONSGROUP BY PARTNOHAVING COUNT(*)=2(14)SELECT SUPPLIERS
9、.SUPPNO,NAME FROM SUPPLIERS,QUOTATIONSWHERE SUPPLIERS.SUPPNO=QUOTATIONS.SUPPNO AND QONORDER100GROUP BY SUPPLIERS.SUPPNO,NAMEHAVING COUNT(*)=2(15)select Q1.SUPPNO,NAME,ADDRESS,PARTNO,PRICE FROM QUOTATIONS Q1,SUPPLIERSWHERE Q1.SUPPNO=SUPPLIERS.SUPPNO AND PRICE (SELECT AVG(PRICE) FROM QUOTATIONS WHERE
10、Q1.PARTNO=PARTNO)(16)第一种方法:SELECT NAME FROM SUPPLIERS WHERE SUPPNO IN(SELECT SUPPNO FROM QUOTATIONS)第二种方法:SELECT DISTINCT NAME FROM SUPPLIERS,QUOTATIONSWHERE QUOTATIONS.SUPPNO=SUPPLIERS.SUPPNO(17)第一种方法:SELECT DISTINCT SUPPNO FROM QUOTATIONS WHERE PARTNO IN(SELECT PARTNO FROM INVENTORY WHERE QONHAND1
11、00) 第二种方法:SELECT DISTINCT SUPPNO FROM QUOTATIONS WHERE exists (SELECT * FROM INVENTORY WHERE QONHAND100 andINVENTORY.PARTNO=QUOTATIONS.PARTNO)SELECT DISTINCT SUPPNO FROM QUOTATIONS,INVENTORYWHERE QONHAND100 AND QUOTATIONS.PARTNO=INVENTORY.PARTNO(18) Insert into Inventory(partno,description) values(L
12、X15,铝线1.5mm)(19) update quotations set qonorder=200 where partno=CZ002 and suppno=57403(20) delete from quotations where suppno=57302Delete from suppliers where suppno=57302第四章 一选择题1、C 2、B 3、D 4、B 5、C 6、A 7、C 8、C 9、C四、综合题2.求(AE )F (1) X(0)=AE,得到 A,E 或 AE 的函数依赖,只有一个 AB(2)X(1)=AE U B,判断 X(0)不等于 X(1) 。
13、(3)X(1)=AEB,得到函数依赖,AB(4)X(2)=AEUB,判断 X(2)等于 X(1)那么(AE)F+=ABE同理(AD)F+=ABCDE第六章一、选择题1、A 2、C 3、D 4、D 5、B第七章一、选择题1、C 2、D 3、B 4、C 5、C 6、不用做 7、D 8、D 9、D 10、B 11.B四、综合题商店 职工工作1 N编号商店名地址 电话月薪进店日期职工编号姓名年龄 性别商店(商店编号,商店名,地址,电话)职工(职工编号,姓名,性别,年龄)工作(商店编号,职工编号,进店日期,月薪)或者:商店(商店编号,商店名,地址,电话)职工(职工编号,姓名,性别,年龄,商店编号,进店日
14、期,月薪)第 9 章一、选择题1、D 2、B 3、C 4、A 5、D 6、C三、综合题(1)Insert into S values(S050101,王晓,女,18, 123456);(2)insert into S(Snum,Sname,Class) values(S050101,王晓, 123456)(3)update S set Sname=刘明 where Snum= S050120(4) update S set Class=654321 where Class=123456(5) delete from S where Snum= S050120(6) delete from S where Sname like 刘