数据库系统基础教程课后答案第五章
数据库系统概论第一章第五章部分习题答案

第一章11 .试给出一个实际部门的 E 一R 图,要求有三个实体型,而且 3 个实体型之间有多对多联系。
3 个实体型之间的多对多联系和三个实体型两两之间的三个多对多联系等价吗?为什么?答:3 个实体型之间的多对多联系和 3 个实体型两两之间的 3 个多对多联系是不等价,因为它们拥有不同的语义。
3 个实体型两两之间的三个多对多联系如下图所示。
12 .学校中有若干系,每个系有若干班级和教研室,每个教研室有若干教员,其中有的教授和副教授每人各带若干研究生;每个班有若干学生,每个学生选修若干课程,每门课可由若干学生选修。
请用 E 一R 图画出此学校的概念模型。
答:13 .某工厂生产若干产品,每种产品由不同的零件组成,有的零件可用在不同的产品上。
这些零件由不同的原材料制成,不同零件所用的材料可以相同。
这些零件按所属的不同产品分别放在仓库中,原材料按照类别放在若干仓库中。
请用 E 一R 图画出此工厂产品、零件、材料、仓库的概念模型。
答:第五章6.假设有下面两个关系模式:职工(职工号,姓名,年龄,职务,工资,部门号),其中职工号为主码;部门(部门号,名称,经理名,电话),其中部门号为主码。
用sQL 语言定义这两个关系模式,要求在模式中完成以下完整性约束条件的定义:定义每个模式的主码;定义参照完整性;定义职工年龄不得超过60 岁。
答CREATE TABLE DEPT(Deptno NUMBER(2),Deptname VARCHAR(10),Manager VARCHAR(10),PhoneNumber Char(12)CONSTRAINT PK_SC PRIMARY KEY(Deptno));CREATE TABLE EMP(Empno NUMBER(4) PRIMARY KEY,Ename VARCHAR(10),Age NUMBER(2),CONSTRAINT C1 CHECK ( Aage<=60),Job VARCHAR(9),Sal NUMBER(7,2),Deptno NUMBER(2),CONSTRAINT FK_DEPTNOFOREIGN KEY(Deptno)REFFERENCES DEPT(Deptno));。
04735数据库系统原理(2021版)课后习题参考答案

04735数据库系统原理(2021版)课后习题参考答案答案仅供参考第一章数据库系统概述选择题B、B、A简答题1.请简述数据,数据库,数据库管理系统,数据库系统的概念。
P27数据是描绘事物的记录符号,是指用物理符号记录下来的,可以鉴别的信息。
数据库即存储数据的仓库,严格意义上是指长期存储在计算机中的有组织的、可共享的数据集合。
数据库管理系统是专门用于建立和管理数据库的一套软件,介于应用程序和操作系统之间。
数据库系统是指在计算机中引入数据库技术之后的系统,包括数据库、数据库管理系统及相关实用工具、应用程序、数据库管理员和用户。
2.请简述早数据库管理技术中,与人工管理、文件系统相比,数据库系统的优点。
数据共享性高数据冗余小易于保证数据一致性数据独立性高可以施行统一管理与控制减少了应用程序开发与维护的工作量3.请简述数据库系统的三级形式和两层映像的含义。
P31答:数据库的三级形式是指数据库系统是由形式、外形式和内形式三级工程的,对应了数据的三级抽象。
两层映像是指三级形式之间的映像关系,即外形式/形式映像和形式/内形式映像。
4.请简述关系模型与网状模型、层次模型的区别。
P35使用二维表构造表示实体及实体间的联络建立在严格的数学概念的根底上概念单一,统一用关系表示实体和实体之间的联络,数据构造简单明晰,用户易懂易用存取途径对用户透明,具有更高的数据独立性、更好的平安保密性。
第二章关系数据库选择题C、C、D简答题1.请简述关系数据库的根本特征。
P48答:关系数据库的根本特征是使用关系数据模型组织数据。
2.请简述什么是参照完好性约束。
P55答:参照完好性约束是指:假设属性或属性组F是根本关系R的外码,与根本关系S的主码K相对应,那么对于R中每个元组在F上的取值只允许有两种可能,要么是空值,要么与S中某个元组的主码值对应。
3.请简述关系标准化过程。
答:对于存在数据冗余、插入异常、删除异常问题的关系形式,应采取将一个关系形式分解为多个关系形式的方法进展处理。
数据库系统第五版课后习题答案

第1章绪论1 .试述数据、数据库、数据库系统、数据库管理系统的概念。
答:( l )数据( Data ) :描述事物的符号记录称为数据。
数据的种类有数字、文字、图形、图像、声音、正文等。
数据与其语义是不可分的。
解析在现代计算机系统中数据的概念是广义的。
早期的计算机系统主要用于科学计算,处理的数据是整数、实数、浮点数等传统数学中的数据。
现代计算机能存储和处理的对象十分广泛,表示这些对象的数据也越来越复杂。
数据与其语义是不可分的。
500 这个数字可以表示一件物品的价格是 500 元,也可以表示一个学术会议参加的人数有 500 人,还可以表示一袋奶粉重 500 克。
( 2 )数据库( DataBase ,简称 DB ) :数据库是长期储存在计算机内的、有组织的、可共享的数据集合。
数据库中的数据按一定的数据模型组织、描述和储存,具有较小的冗余度、较高的数据独立性和易扩展性,并可为各种用户共享。
( 3 )数据库系统( DataBas 。
Sytem ,简称 DBS ) :数据库系统是指在计算机系统中引入数据库后的系统构成,一般由数据库、数据库管理系统(及其开发工具)、应用系统、数据库管理员构成。
解析数据库系统和数据库是两个概念。
数据库系统是一个人一机系统,数据库是数据库系统的一个组成部分。
但是在日常工作中人们常常把数据库系统简称为数据库。
希望读者能够从人们讲话或文章的上下文中区分“数据库系统”和“数据库”,不要引起混淆。
( 4 )数据库管理系统( DataBase Management sytem ,简称 DBMs ) :数据库管理系统是位于用户与操作系统之间的一层数据管理软件,用于科学地组织和存储数据、高效地获取和维护数据。
DBMS 的主要功能包括数据定义功能、数据操纵功能、数据库的运行管理功能、数据库的建立和维护功能。
解析 DBMS 是一个大型的复杂的软件系统,是计算机中的基础软件。
目前,专门研制 DBMS 的厂商及其研制的 DBMS 产品很多。
数据库原理与应用教程第四版 第五章答案

免责声明:私人学习之余整理,如有错漏,概不负责1.视图的优点简化数据查询语句、使用户能从多角度看待同一数据、提高了数据的安全性、提供了一定程度的逻辑独立性2.使用视图可以加快数据的查询速度吗?为什么?不对。
其本质上还是执行视图内部的查询语句,通过视图查询数据时,都是转换为对基本表的查询,其简化了数据查询语句但是并不能加快数据查询速度。
3.写出创建满足以下要求的视图的SQL语句。
1)查询学生的学号、姓名、所在系、课程号、课程名、课程学分。
CREATE VIEW v1(Sno,Sname,Sdept,Cno,Cname,Credit)ASSELECT s.Sno,Sname,Sdept,o,Cname,CreditFROM Student s JOIN SC ON s.Sno = SC.Sno JOIN Course c ON o = o2)查询学生的学号、姓名、选修的课程名和考试成绩。
CREATE VIEW v2(Sno,Sname,Cname,Grade)ASSELECT s.Sno,Sname,Cname,GradeFROM Student s JOIN SC ON s.Sno = SC.Sno JOIN Course c ON o = o3)统计每个学生的选课门数,列出学生学号和选课门数。
CREATE VIEW v3(Sno,选课门数)ASSELECT s.Sno,COUNT(*)FROM Student s JOIN SC ON s.Sno = SC.SnoGROUP BY Sno4)统计每个学生的修课总学分,列出学生学号和总学分。
(成绩大于等于60)CREATE VIEW v4(Sno,总学分)ASSELECT s.Sno,SUM(Credit)FROM Student s JOIN SC ON s.Sno = SC.Sno JOIN Course c ON o = oWHERE Grade > 60GROUP BY Sno5)查询计算机系Java考试成绩最高的学生的学号、姓名和Java考试成绩。
数据库实用教程(第三版)董建全数据库第五章答案

数据库实用教程(第三版)董建全数据库第五章答案5.2..设关系模式R(ABC),如果规定.定,.关系中B值与D值之间是一对多联系,A值与C值之间是一对一联系。
试写出相应的函.数依赖。
答:从B值与D值之间是一对多联系,可写出函数依赖D→B,从A值与C值之间是一对一联系,可写出函数依赖A→C和C→A。
5.3设关系模式R(ABCD),F是R上成立的FD集,F|={A→B,C→B},则相对于F,试写出.关系模式R的关键码。
并说明理由。
答:R的关键码为ACD,因为从已知的F,只能推出ACD→ABCD5.4试解释数据库“丢失信息”与“未丢失信息”两个概念。
“丢失信息”与“丢失数据”有什么区别?5.5设关系模式R(WNO,WS,WG)的属性分别表示职工的工号、工资级别和工资数目。
F是R上成立的FD集,F={WNO→WS,WS→WG}。
将R分解成ρ={R1,R2},其中R1={WNO,WS},R2={WNO,WG}。
那么,丢失的FD是(WS→WG)。
5.6设关系模式R(ABC),F是R上成立的FD集,F={B→C,C→A},那么分解ρ={AB,BC}相对于F,是否无损分解和保持FD?说明理由。
5.7设关系模式R(ABCD),R上的FD集F={A→C,D→C,BD→A},试说明ρ={AB,ACD,BCD}相对于F是损失分解的理由。
答:据已知的F集,不可能把初始表格修改为有一个全a行的表格,因此ρ相对于F 是损失分解。
5.8设有关系模式R(职工名,项目名,工资,部门名,部门经理),如果规定每个职工可参加多个项目,各领一份工资;每个项目只属于一个部门管理;每个部门只有一个经理。
①试写出关系模式R的基本FD和关键码。
②说明R不是2NF模式的理由,并把R分解成2NF模式集。
③进而把R分解成3NF模式集,并说明理由。
答:⑴R的基本FD有三个:(职工名,项目名)→工资项目名→部门名部门名→部门经理关键码为(职工名,项目名)。
数据库系统概论第五章完整性

一、选择题1.实体完整性要求主属性不能取空值,这一点可通过( )来保证。
A .定义外部键B .定义主键C .用户定义的完整性D .由关系系统自动答案:B2. ( )定义了对参照关系的外部属性值域的约束。
A .实体完整性规则B .用户定义的完整性规则C .参照完整性规则D .以上均不是答案:C3.在如下2个数据库的表中,若雇员信息表EMP 的主键是雇员号,部门信息表DEPT 的主键是部门号。
若执行所列出的操作,哪个操作不能执行( )EMP DEPTA .从雇员信息表EMP 中删除行(’010’,’’王利,’01’,’1200’)B .在雇员信息表EMP 中插入行(’102’,’赵丽’,’01’,’1500’)C .将雇员信息表EMP 中雇员号=’010’的工资改为1600元D .将雇员信息表EMP 中雇员号=’101’的部门号改为’05’答案:D4.关系数据库中,实现主码标识元组的作用是通过( )A .实体完整性规则B .参照完整性规则C .用户自定义的完整性D .属性的值域答案:A5.在关系数据库中,实现“表中任意两行不能相同”的约束是靠( )A .外码B .主码C .属性D .列答案:B6.关系数据库中,实现表与表之间的联系是通过( )A .实体完整性规则B .参照完整性规则C .用户自定义的完整性D .值域答案:B雇员号 雇员名 部门号 工资001 张红 02 2000 010 王利 01 1200056 马明 02 1000101 赵丽 04 1500 部门号 部门名 主任 01 业务部 李林02 销售部 江平 03 服务部 周明 04 财务部 陈胜7.根据关系模式的完整性规则,一个关系中的“主键”()A.不能有两个B.不能成为另一个关系的外部键C.不允许为空D.可以取空值答案:C8.在关系模型中,实现“关系中不允许发现相同的元组”的约束是通过()A.候选键B.主键C.外键D.一般键答案:B二、填空题1.为了维护数据库中数据的完整性,在对关系数据库执行插入时首先应检查__________规则。
数据库系统原理及应用教程第四版课后答案苗雪兰第5章(ppt文档)

服务功能
数据库引擎:核心服务,是存储和处理关系的 数据或XML文档数据的服务,完成数据的存储、 处理和安全管理。例如,创建数据库、创建表、 创建视图、数据查询、访问数
Analysis Services:提供联机分析处理 (OLAP)和数据挖掘功能。
Reporting Services(报表服务):提供图形 工具和向导,用于创建和发布报表;管理报表 服务器;对对象模型进行编程和扩展的应用程 序编程接口(API)。
2008年,微软公司发布了SQL Server 2008,该版本为各类 用户提供完整的数据库解决方案,帮助用户建立自己的电 子商务体系,增强用户对外界变化的敏捷反应能力,提高 用户的市场竞争力。
5.1.1 N-Tier客户机∕服务器结构
1. 桌面型数据库系统和客户机/服务器型数据库系统
桌面型数据库系统:SQL Server和数据库都安装在客户端计 算机中。客户机/服务器型数据库系统:系统安装在网络服务 器中,数据库为网络中的客户机应用程序共享。
③事件探查器是SQL Server一种性能优化工具,用于监视 与分析SQL服务器活动、网络进出流量或事件等。 ④数据库引擎优化顾问是SQL Server系统优化工具,可以 帮助用户进行数据库引擎方面的优化服务。
SQL Server发展简史 SQL Server的第一个版本是由微软公司和Sybase公司在 1988年合作开发的。
从1992年到1998年,微软公司相继开发了SQL Server的 Windows NT平台版本的SQL Server 4.2版本、6.0版本、6.5 版本和7.0版本。
2000年,SQL Server 2000版本正式面世。该版本在数据库 性能、数据可靠性、易用性方面做了重大改进。
数据库系统概论(第五版)王珊第五章课后习题答案

数据库系统概论(第五版)王珊第五章课后习题答案1什么是数据库的完整性?答:数据库的完整性是指数据的正确性和相容性。
2 .数据库的完整性概念与数据库的安全性概念有什么区别和联系?答:数据的完整性和安全性是两个不同的概念,但是有⼀定的联系。
前者是为了防⽌数据库中存在不符合语义的数据,防⽌错误信息的输⼊和输出,即所谓垃圾进垃圾出( Garba : e In Garba : e out )所造成的⽆效操作和错误结果。
后者是保护数据库防⽌恶意的破坏和⾮法的存取。
也就是说,安全性措施的防范对象是⾮法⽤户和⾮法操作,完整性措施的防范对象是不合语义的数据。
3 .什么是数据库的完整性约束条件?可分为哪⼏类?答完整性约束条件是指数据库中的数据应该满⾜的语义约束条件。
⼀般可以分为六类:静态列级约束、静态元组约束、静态关系约束、动态列级约束、动态元组约束、动态关系约束。
静态列级约束是对⼀个列的取值域的说明,包括以下⼏个⽅⾯: ( l )对数据类型的约束,包括数据的类型、长度、单位、精度等; ( 2 )对数据格式的约束; ( 3 )对取值范围或取值集合的约束; ( 4 )对空值的约束; ( 5 )其他约束。
静态元组约束就是规定组成⼀个元组的各个列之间的约束关系,静态元组约束只局限在单个元组上。
静态关系约束是在⼀个关系的各个元组之间或者若⼲关系之间常常存在各种联系或约束。
常见的静态关系约束有: ( l )实体完整性约束; ( 2 )参照完整性约束; ( 3 )函数依赖约束。
动态列级约束是修改列定义或列值时应满⾜的约束条件,包括下⾯两⽅⾯: ( l )修改列定义时的约束; ( 2 )修改列值时的约束。
动态元组约束是指修改某个元组的值时需要参照其旧值,并且新旧值之间需要满⾜某种约束条件。
动态关系约束是加在关系变化前后状态上的限制条件,例如事务⼀致性、原⼦性等约束条件。
4 . DBMS 的完整性控制机制应具有哪些功能?答:DBMS 的完整性控制机制应具有三个⽅⾯的功能: ( l )定义功能,即提供定义完整性约束条件的机制; ( 2 )检查功能,即检查⽤户发出的操作请求是否违背了完整性约束条件;( 3 )违约反应:如果发现⽤户的操作请求使数据违背了完整性约束条件,则采取⼀定的动作来保证数据的完整性。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Exercise 5.1.1 As a set:Average = 2.37 As a bag:Average = 2.48 Exercise 5.1.2 As a set:Average = 218 As a bag:Average = 215 Exercise 5.1.3a As a set:As a bag:Exercise 5.1.3bπbore(Ships Classes)Exercise 5.1.4aFor bags:On the left-hand side:Given bags R and S where a tuple t appears n and m times respectively, the union of bags R and S will have tuple t appear n + m times. The further union of bag T with the tuple t appearing o times will have tuple t appear n + m + o times in the final result.On the right-hand side:Given bags S and T where a tuple t appears m and o times respectively, the union of bags R and S will have tuple t appear m + o times. The further union of bag R with the tuple t appearing n times will have tuple t appear m + o + n times in the final result.For sets:This is a similar case when dealing with bags except the tuple t can only appear at most once in each set. The tuple t only appears in the result if all the sets have the tuple t. Otherwise, the tuple t will not appear in the result. Since we cannot have duplicates, the result only has at most one copy of the tuple t.Exercise 5.1.4bFor bags:On the left-hand side:Given bags R and S where a tuple t appears n and m times respectively, the intersectionof bags R and S will have tuple t appear min( n, m ) times. The further intersection of bag T with the tuple t appearing o times will produce tuple t min( o, min( n, m ) ) times in the final result.On the right-hand side:Given bags S and T where a tuple t appears m and o times respectively, the intersection of bags R and S will have tuple t appear min( m, o ) times. The further intersection of bag R with the tuple t appearing n times will produce tuple t min( n, min( m, o ) ) times in thefinal result.The intersection of bags R,S and T will yield a result where tuple t appears min( n,m,o ) times. For sets:This is a similar case when dealing with bags except the tuple t can only appear at most once in each set. The tuple t only appears in the result if all the sets have the tuple t. Otherwise, the tuple t will not appear in the result.Exercise 5.1.4cFor bags:On the left-hand side:Given that tuple r in R, which appears m times, can successfully join with tuple s in S,which appears n times, we expect the result to contain mn copies. Also given that tuple tin T, which appears o times, can successfully join with the joined tuples of r and s, weexpect the final result to have mno copies.On the right-hand side:Given that tuple s in S, which appears n times, can successfully join with tuple t in T,which appears o times, we expect the result to contain no copies. Also given that tuple rin R, which appears m times, can successfully join with the joined tuples of s and t, weexpect the final result to have nom copies.The order in which we perform the natural join does not matter for bags.For sets:This is a similar case when dealing with bags except the joined tuples can only appear at most once in each result. If there are tuples r,s,t in relations R,S,T that can successfully join, then the result will contain a tuple with the schema of their joined attributes.Exercise 5.1.4dFor bags:Suppose a tuple t occurs n and m times in bags R and S respectively. In the union of these two bags R ⋃ S, tuple t would appear n + m times. Likewise, in the union of these two bags S ⋃ R, tuple t would appear m + n times. Both sides of the relation yield the same result.For sets:A tuple t can only appear at most one time. Tuple t might appear each in sets R and S one or zero times. The combinations of number of occurrences for tuple t in R and S respectively are (0,0), (0,1), (1,0), and (1,1). Only when tuple t appears in both sets R and S will the union R ⋃ S have the tuple t. The same reasoning holds when we take the union S ⋃ R.Therefore the commutative law for union holds.Exercise 5.1.4eFor bags:Suppose a tuple t occurs n and m times in bags R and S respectively. In the intersection of these two bags R ∩ S, tuple t would appear min( n,m ) times. Likewise in the intersection of these two bags S ∩ R, tuple t would appear min( m,n ) times. Both sides of the relation yield the same result.For sets:A tuple t can only appear at most one time. Tuple t might appear each in sets R and S one or zero times. The combinations of number of occurrences for tuple t in R and S respectively are (0,0), (0,1), (1,0), and (1,1). Only when tuple t appears in at least one of the sets R and S will the intersection R ∩ S have the tuple t. The same reasoning holds when we take the intersection S ∩ R.Therefore the commutative law for intersection holds.Exercise 5.1.4fFor bags:Suppose a tuple t occurs n times in bag R and tuple u occurs m times in bag S. Suppose also that the two tuples t,u can successfully join. Then in the natural join of these two bags R S, the joined tuple would appear nm times. Likewise in the natural join of these two bags S R, the joined tuple would appear mn times. Both sides of the relation yield the same result.For sets:An arbitrary tuple t can only appear at most one time in any set. Tuples u,v might appear respectively in sets R and S one or zero times. The combinations of number of occurrences for tuples u,v in R and S respectively are (0,0), (0,1), (1,0), and (1,1). Only when tuple u exists in Rand tuple v exists in S will the natural join R S have the joined tuple. The same reasoning holds when we take the natural join S R.Therefore the commutative law for natural join holds.Exercise 5.1.4gFor bags:Suppose tuple t appears m times in R and n times in S. If we take the union of R and S first, we will get a relation where tuple t appears m + n times. Taking the projection of a list of attributes L will yield a resulting relation where the projected attributes from tuple t appear m + n times. If we take the projection of the attributes in list L first, then the projected attributes from tuple t would appear m times from R and n times from S. The union of these resulting relations would have the projected attributes of tuple t appear m + n times.For sets:An arbitrary tuple t can only appear at most one time in any set. Tuple t might appear in sets R and S one or zero times. The combinations of number of occurrences for tuple t in R and S respectively are (0,0), (0,1), (1,0), and (1,1). Only when tuple t exists in R or S (or both R and S) will the projected attributes of tuple t appear in the result.Therefore the law holds.Exercise 5.1.4hFor bags:Suppose tuple t appears u times in R, v times in S and w times in T. On the left hand side, the intersection of S and T would produce a result where tuple t would appear min(v , w) times. With the addition of the union of R, the overall result would have u + min(v , w) copies of tuple t. On the right hand side, we would get a result of min(u + v, u + w) copies of tuple t. The expressions on both the left and right sides are equivalent.For sets:An arbitrary tuple t can only appear at most one time in any set. Tuple t might appear in sets R,S and T one or zero times. The combinations of number of occurrences for tuple t in R, S and T respectively are (0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0) and (1,1,1). Only when tuple t appears in R or in both S and T will the result have tuple t.Therefore the distributive law of union over intersection holds.Exercise 5.1.4iSuppose that in relation R, u tuples satisfy condition C and v tuples satisfy condition D. Suppose also that w tuples satisfy both conditions C and D where w≤ min(v , w). Then the left hand side will return those w tuples. On the right hand side, σC(R) produces u tuples and σD(R) produces v tuples. However, we know the intersection will produce the same w tuples in the result.When considering bags and sets, the only difference is bags allow duplicate tuples while sets only allow one copy of the tuple. The example above applies to both cases.Therefore the law holds.Exercise 5.1.5aFor sets, an arbitrary tuple t appears on the left hand side if it appears in both R,S and not in T. The same is true for the right hand side.As an example for bags, suppose that tuple t appears one time each in both R,T and two times in S. The result of the left hand side would have zero copies of tuple t while the right hand side would have one copy of tuple t.Therefore the law holds for sets but not for bags.Exercise 5.1.5bFor sets, an arbitrary tuple t appears on the left hand side if it appears in R and either S or T. This is equivalent to saying tuple t only appears when it is in at least R and S or in R and T. The equivalence is exactly the right side’s expression.As an example for bags, suppose that tuple t appears one time in R and two times each in S and T. Then the left hand side would have one copy of tuple t in the result while the right hand side would have two copies of tuple t.Therefore the law holds for sets but not for bags.Exercise 5.1.5cFor sets, an arbitrary tuple t appears on the left hand side if it satisfies condition C, condition Dor both condition C and D. On the right hand side, σC(R) selects those tuples that satisfy condition C while σD(R) selects those tuples that satisfy condition D. However, the union operator will eliminate duplicate tuples, namely those tuples that satisfy both condition C and D. Thus we are ensured that both sides are equivalent.As an example for bags, we only need to look at the union operator. If there are indeed tuples that satisfy both conditions C and D, then the right hand side will contain duplicate copies of those tuples. The left hand side, however, will only have one copy for each tuple of the original set of tuples.Exercise 5.2.1bExercise 5.2.1cExercise 5.2.1dExercise 5.2.1fExercise 5.2.1gExercise 5.2.1hExercise 5.2.1iExercise 5.2.1jExercise 5.2.1kExercise 5.2.1lExercise 5.2.1mExercise 5.2.1nExercise 5.2.2aApplying the δ operator on a relation with no duplicates will yield the same relation. Thus δ is idempotent.Exercise 5.2.2bThe result of πL is a relation over the list of attributes L. Performing the projection again will return the same relation because the relation only contains the list of attributes L. Thus πL is idempotent.Exercise 5.2.2cThe result of σC is a relation where condition C is satisfied by every tuple. Performing the selection again will return the same relation because the relation only contains tuples that satisfy the condition C. Thus σC is idempotent.Exercise 5.2.2dThe result of γL is a relation whose schema consists of the grouping attributes and the aggregated attributes. If we perform the same grouping operation, there is no guarantee that the expression would make sense. The grouping attributes will still appear in the new result. However, the aggregated attributes may or may not appear correctly. If the aggregated attribute is given a different name than the original attribute, then performing γL would not make sense because it contains an aggregation for an attribute name that does not exist. In this case, the resultingrelation would, according to the definition, only contain the grouping attributes. Thus, γL is not idempotent.Exercise 5.2.2eThe result of τ is a sorted list of tuples based on some attributes L. If L is not the entire schema of relation R, then there are attributes that are not sorted on. If in relation R there are two tuples that agree in all attributes L and disagree in some of the remaining attributes not in L, then it is arbitrary as to which order these two tuples appear in the result. Thus, performing the operation τ multiple times can yield a different relation where these two tuples are swapped. Thus, τ is not idempotent.Exercise 5.2.3If we only consider sets, then it is possible. We can take πA(R) and do a product with itself. From this product, we take the tuples where the two columns are equal to each other.If we consider bags as well, then it is not possible. Take the case where we have the two tuples (1,0) and (1,0). We wish to produce a relation that contains tuples (1,1) and (1,1). If we use the classical operations of relational algebra, we can either get a result where there are no tuples or four copies of the tuple (1,1). It is not possible to get the desired relation because no operation can distinguish between the original tuples and the duplicated tuples. Thus it is not possible to get the relation with the two tuples (1,1) and (1,1).Exercise 5.3.1a)Answer(model) ← PC(model,speed,_,_,_) AND speed ≥ 3.00b)Answer(maker) ← Laptop(model,_,_,hd,_,_) AND Product(maker,model,_) AND hd ≥100c)Answer(model,price) ← PC(model,_,_,_,price) AND Product(maker,model,_) ANDmaker=’B’Answer(model,price) ← Laptop(mode l,_,_,_,_,price) AND Product(maker,model,_)AND maker=’B’Answer(model,price) ← Printer(model,_,_,price) AND Product(maker,model,_) ANDmaker=’B’d)Answer(model) ← Printer(model,color,type,_) AND color=’true’ AND type=’laser’e)PCMaker(maker) ← Product(maker,_,type) AND type=’pc’LaptopMaker(maker) ← Product(maker,_,type) AND type=’laptop’Answer(maker) ← LaptopMaker(maker) AND NOT PCMaker(maker)f)Answer(hd) ← PC(model1,_,_,hd,_) AND PC(model2,_,_,hd,_) AND model1 <>model2g)Answer(model1,model2) ← PC(model1,speed, ram,_,_) ANDPC(model2,_speed,ram,_,_) AND model1 < model2h)FastComputer(model) ← PC(model,speed,_,_,_) AND speed ≥ 2.80FastComputer(model) ← Laptop(model,speed,_,_,_,_) AND speed ≥ 2.80Answer(maker) ← Product(maker,model1,_) AND Product(maker,mod el2,_) ANDFastComputer(model1) AND FastComputer(model2) AND model1 <> model2i)Computers(model,speed) ← PC(model,speed,_,_,_)Computers(model,speed) ← Laptop(model,speed,_,_,_,_)SlowComputers(model) ← Computers(model,speed) AND Computers(model1,speed1)AND speed < speed1FastestComputers(model) ← Computers(model,_) AND NOT SlowComputers(model)Answer(maker) ← Fast estComputers(model) AND Product(maker,model,_)j)PCs(maker,speed) ← PC(model,speed,_,_,_) AND Product(maker,model,_) Answer(maker) ← PCs(maker,spe ed) AND PCs(maker,speed1) AND PCs(maker,speed2) AND speed <> speed1 AND speed <> speed2 AND speed1 <> speed2k)PCs(maker,model) ← Product(maker,model,type) AND type=’pc’Answer(maker) ← PCs(maker,model) AND PCs(maker,model1) ANDPCs(maker,model2) AND PCs(maker,model3) AND model <> model1 AND model <>model2 AND model1 <> model2 AND (model3 = model OR model3 = model1 ORmodel3 = model2)Exercise 5.3.2a)Answer(class,country) ← Classes(class,_,country,_,bore,_) AND bore ≥ 16b)Answer(name) ← Ships(name,_,launch ed) AND launched < 1921c)Answer(ship) ← Outcomes(ship,battle,result) AND battle=’Denmark Strait’ AND result= ‘sunk’d)Answer(name) ← Classes(class,_,_,_,_,displacement) AND Ships(name,class,launched)AND displacement > 35000 AND launched > 1921e)Answer(nam e,displacement,numGuns) ← Classes(class,_,_,numGuns,_,displacement)AND Ships(name,class,_) AND Outcomes (ship,battle,_) AND battle=’Guadalcanal’AND ship=namef)Answer(name) ← Ships(name,_,_)Answer(name) ← Outcomes(name,_,_) AND NOT Answer(name)g)MoreThan One(class) ← Ships(name,class,_) AND Ships(name1,class,_) AND name <>name1Answer(class) ← Classes(class,_,_,_,_,_) AND NOT MoreThanOne(class)h)Battleship(country) ← Classes(_,type,country,_,_,_) AND type=’bb’Battlecruiser(country) ← Classes(_,type,country,_,_,_) AND type=’bc’Answer(country) ← Battleship(country) AND Battlecruiser(country)i)Results(ship,result,date) ← Battles(name,date) AND Outcomes(ship,battle,result) ANDbattle=nameAnswer(ship) ← Results(ship,result,date) AND Results(ship,_,date1) ANDresult=’damaged’ AND date < date1Exercise 5.3.3A nswer(x,y) ← R(x,y) AND z = zExercise 5.4.1aAnswer(a,b,c) ← R(a,b,c)Answer(a,b,c) ← S(a,b,c)Exercise 5.4.1bAnswer(a,b,c) ← R(a,b,c) AND S(a,b,c)Exercise 5.4.1cAnswer(a,b,c) ← R(a,b,c) AND NOT S(a,b,c)Exercise 5.4.1dUnion(a,b,c) ← R(a,b,c)Union(a,b,c) ← S(a,b,c)Answer(a,b,c) ← Union(a,b,c) AND NOT T(a,b,c)Exercise 5.4.1eJ(a,b,c) ← R(a,b,c) AND NOT S(a,b,c)K(a,b,c) ← R(,a,b,c) AND NOT T(a,b,c)Answer(a,b,c) ← J(a,b,c) AND K(a,b,c)Exercise 5.4.1fAnswer(a,b) ← R(a,b,_)Exercise 5.4.1gJ(a,b) ← R(a,b,_)K(a,b) ← S(_,a,b)Answer(a,b) ← J(a,b) AND K(a,b)Exercise 5.4.2aAnswer(x,y,z) ← R(x,y,z) AND x = yExercise 5.4.2bAnswer(x,y,z) ← R(x,y,z) AND x < y AND y < z Exercise 5.4.2cAnswer(x,y,z) ← R(x,y,z) AND x < yAnswer(x,y,z) ← R(x,y,z) AND y < zExercise 5.4.2dChange: NOT(x < y OR x > y)To: x ≥ y AND x ≤ yThe above simplifies to x = yAnswer(x,y,z) ← R(x,y,z) AND x = yExercise 5.4.2eChange: NOT((x < y OR x > y) AND y < z)NOT(x < y OR x > y) OR y ≥ z(x ≥ y AND x ≤ y) OR y ≥ zTo: x = y OR y ≥ zAnswer(x,y,z) ← R(x,y,z) AND x = yAnswer(x,y,z) ← R(x,y,z) AND y ≥ zExercise 5.4.2fChange: NOT((x < y OR x < z) AND y < z)NOT(x < y OR x < z) OR y ≥ z To: (x ≥ y AND x ≥ z) OR y ≥ zAnswer(x,y,z) ← R(x,y,z) AND x ≥ y AND x ≥ zAnswer(x,y,z) ← R(x,y,z) AND y ≥zExercise 5.4.3aAnswer(a,b,c,d) ← R(a,b,c) AND S(b,c,d)Exercise 5.4.3bAnswer(b,c,d,e) ← S(b,c,d) AND T(d,e)Exercise 5.4.3cAnswer(a,b,c,d,e) ← R(a,b,c) AND S(b,c,d) AND T(d,e)Exercise 5.4.4a)Answer(rx,ry,rz,sx,sy,sz) ← R(rx,ry,rz) AND S(sx,sy,sz) AND rx = syb)Answer(rx,ry,rz,sx,sy,sz) ← R(rx,ry,rz) AND S(sx,sy,sz) AND rx < sy AND ry < szc)Answer(rx,ry,rz,sx,sy,s z) ← R(rx,ry,rz) AND S(sx,sy,sz) AND rx < syAnswer(rx,ry,rz,sx,sy,sz) ← R(rx,ry,rz) AND S(sx,sy,sz) AND ry < szd)Answer(rx,ry,rz,sx,sy,sz) ← R(rx,ry,rz) AND S(sx,sy,sz) AND rx = sye)Answer(rx,ry,rz,sx,sy,sz) ← R(rx,ry,rz) AND S(sx,sy,sz) AND rx = syAnswe r(rx,ry,rz,sx,sy,sz) ← R(rx,ry,rz) AND S(sx,sy,sz) AND ry ≥ szf)Answer(rx,ry,rz,sx,sy,sz) ← R(rx,ry,rz) AND S(sx,sy,sz) AND rx ≥ sy AND rx ≥ szAnswer(rx,ry,rz,sx,sy,sz) ← R(rx,ry,rz) AND S(sx,sy,sz) AND ry ≥ szExercise 5.4.5aR1 := πx,y(Q R)Exercise 5.4.5bR1 := ρR1(x,z)(Q)R2 := ρR2(z,y)(Q)R3 := πx,y(R1 (R1.z = R2.z) R2)Exercise 5.4.5cR1 := πx,y(Q R)R2 := σx < y(R1)。