数据库实用教程(第三版)董建全数据库第五章答案
数据库第五章习题及答案

数据库第五章习题及答案本文档为数据库第五章的习题及答案,帮助读者巩固数据库相关知识。
习题1. 数据库的优点有哪些?数据库具有以下优点: - 数据共享:多个用户可以同时访问和共享数据库中的数据。
- 数据一致性:数据库提供事务管理能力,保证了数据的一致性。
- 数据持久性:数据在数据库中是永久存储的,不会因为系统关机或程序结束而丢失。
- 数据冗余度低:数据库通过规范化设计,减少了数据的冗余性,提高了数据的存储效率。
- 数据独立性:数据库支持数据与应用程序的独立性,提高了系统的灵活性和维护性。
- 数据安全性:数据库提供了用户权限管理和数据备份机制,保证了数据的安全性。
2. 数据库的三级模式结构是什么?数据库的三级模式结构包括: - 外模式(视图层):外模式是用户所看到的数据库的子集,用于描述用户对数据库的逻辑视图。
每个用户可以有不同的外模式来满足自己的需求。
- 概念模式(逻辑层):概念模式是全局数据库的逻辑结构和组织方式,描述了数据的总体逻辑视图。
概念模式独立于具体的应用程序,是数据库管理员的角度来看待数据库的。
- 内模式(物理层):内模式是数据库的存储结构和物理组织方式,描述了数据在存储介质上的实际存储方式。
3. 数据库的完整性约束有哪些?数据库的完整性约束包括: - 实体完整性约束:确保表的主键不为空,每个实体都能够唯一标识。
- 参照完整性约束:确保外键的引用关系是有效的,即外键值必须等于被引用表中的主键值或者为空。
- 用户定义完整性约束:用户可以自定义额外的完整性约束,如检查约束、唯一约束、默认约束等。
4. 数据库的关系模型有哪些特点?数据库的关系模型具有以下特点: - 数据用二维表的形式进行组织,表由行和列组成,每一行表示一个实体,每一列表示一个属性。
- 表与表之间通过主键和外键建立关联关系,形成关系。
- 关系模型提供了一种数据独立性的设计方法,使得应用程序与数据的逻辑结构相分离,提高了系统的灵活性和可维护性。
数据库实用教程(第三版)董建全数据库第五章答案

数据库实用教程(第三版)董建全数据库第五章答案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有三个:(职工名,项目名)→工资项目名→部门名部门名→部门经理关键码为(职工名,项目名)。
数据库实用教程答案(第三版)董健全--清华大学出版社

数据库实用教程答案(第三版).doc第1、2章1.1 名词解释:◆DB:数据库(Database),DB是统一管理的相关数据的集合。
DB能为各种用户共享,具有最小冗余度,数据间联系密切,而又有较高的数据独立性。
◆DBMS:数据库管理系统(Database Management System),DBMS 是位于用户与操作系统之间的一层数据管理软件,为用户或应用程序提供访问DB的方法,包括DB的建立、查询、更新及各种数据控制。
DBMS总是基于某种数据模型,可以分为层次型、网状型、关系型、面向对象型DBMS。
◆DBS:数据库系统(Database System),DBS是实现有组织地、动态地存储大量关联数据,方便多用户访问的计算机软件、硬件和数据资源组成的系统,即采用了数据库技术的计算机系统。
◆1:1联系:如果实体集E1中的每个实体最多只能和实体集E2中的一个实体有联系,反之亦然,好么实体集E1对E2的联系称为“一对一联系”,记为“1:1”。
◆1:N联系:如果实体集E1中每个实体与实体集E2中任意个(零个或多个)实体有联系,而E2中每个实体至多和E1中的一个实体有联系,那么E1对E2的联系是“一对多联系”,记为“1:N”。
◆M:N联系:如果实体集E1中每个实体与实体集E2中任意个(零个或多个)实体有联系,反之亦然,那么E1对E2的联系是“多对多联系”,记为“M:N”。
◆数据模型:表示实体类型及实体类型间联系的模型称为“数据模型”。
它可分为两种类型:概念数据模型和结构数据模型。
◆概念数据模型:它是独门于计算机系统的模型,完全不涉及信息在系统中的表示,只是用来描述某个特定组织所关心的信息结构。
◆结构数据模型:它是直接面向数据库的逻辑结构,是现实世界的第二层抽象。
这类模型涉及到计算机系统和数据库管理系统,所以称为“结构数据模型”。
结构数据模型应包含:数据结构、数据操作、数据完整性约束三部分。
它主要有:层次、网状、关系三种模型。
数据库原理与应用教程第三版课后答案

习题参考答案第1 章数据库概述2.与文件管理相比,数据库管理有哪些优点?答:将相互关联的数据集成在一起,具有较少的数据冗余,程序与数据相互独立,保证数据的安全可靠,最大限度地保证数据的正确性,数据可以共享并能保证数据的一致性。
3.比较文件管理和数据库管理数据的主要区别。
答:数据库系统与文件系统相比实际上是在应用程序和存储数据的数据库之间增加了一个系统软件,即数据库管理系统,使得以前在应用程序中由开发人员实现的很多繁琐的操作和功能,都可以由这个系统软件完成,这样应用程序不再需要关心数据的存储方式,而且数据的存储方式的变化也不再影响应用程序。
而在文件系统中,应用程序和数据的存储是紧密相关的,数据的存储方式的任何变化都会影响到应用程序,因此不利于应用程序的维护。
4.数据库管理方式中,应用程序是否需要关心数据的存储位置和结构?为什么?答:不需要。
因为在数据库系统中,数据的存储位置以及存储结构保存在数据库管理系统中,从数据到物理存储位置的转换是由数据库管理系统自动完成的。
6.在数据库系统中,应用程序可以不通过数据库管理系统而直接访问数据库文件吗?答:不能。
7.数据独立性指的是什么?它能带来哪些好处?答:数据独立性指的是数据的逻辑独立性和物理独立性。
逻辑独立性带来的好处是当表达现实世界信息的逻辑结构发生变化时,可以不影响应用程序;物理独立性带来的好处是当数据的存储结构发生变化时,可以不影响数据的逻辑组织结构,从而也不影响应用程序。
8.数据库系统由哪几部分组成,每一部分在数据库系统中的作用大致是什么?答:数据库系统由三个主要部分组成,即数据库、数据库管理系统和应用程序。
数据库是数据的汇集,它以一定的组织形式存于存储介质上;数据库管理系统是管理数据库的系统软件,它可以实现数据库系统的各种功能;应用程序指以数据库数据为核心的应用程序。
9.在文件服务器结构和客户/服务器结构中,对数据的处理有什么区别?.k5.在数据库系统中,数据库的作用是什么?答:在数据库系统中,数据库是存放数据的场所。
数据库第三版课后习题答案

数据库第三版课后习题答案数据库第三版课后习题答案在学习数据库的过程中,课后习题是巩固知识的重要方式。
本文将为大家提供数据库第三版课后习题的答案,希望对大家的学习有所帮助。
第一章:数据库基础1. 数据库是什么?答:数据库是一个存储、管理和操作数据的集合。
它可以用来存储和检索大量数据,并提供数据的安全性和完整性。
2. 数据库管理系统(DBMS)的作用是什么?答:DBMS是一种软件,用于管理数据库。
它提供了对数据库的访问和操作,包括数据的增删改查、数据安全性和完整性的控制、数据备份和恢复等功能。
3. 数据库系统的组成部分有哪些?答:数据库系统由数据库、数据库管理系统和应用程序组成。
数据库是存储数据的仓库,数据库管理系统用于管理和操作数据库,应用程序用于访问和处理数据库中的数据。
4. 什么是关系型数据库?答:关系型数据库是一种基于关系模型的数据库。
它使用表格(称为关系)来组织和存储数据,每个表格包含行和列,行表示记录,列表示属性。
第二章:SQL基础1. SQL是什么?答:SQL(Structured Query Language)是一种用于管理关系型数据库的语言。
它可以用来创建、修改和查询数据库中的数据。
2. SQL语句分为哪几类?答:SQL语句分为数据定义语言(DDL)、数据操作语言(DML)、数据查询语言(DQL)和数据控制语言(DCL)四类。
3. 什么是DDL语句?举例说明。
答:DDL语句用于定义数据库的结构和模式,包括创建表格、修改表格结构、删除表格等。
例如,创建表格的语句如下:CREATE TABLE student (id INT PRIMARY KEY,name VARCHAR(50),age INT);4. 什么是DML语句?举例说明。
答:DML语句用于操作数据库中的数据,包括插入、更新和删除数据。
例如,插入数据的语句如下:INSERT INTO student (id, name, age) VALUES (1, 'Tom', 20);第三章:关系数据库设计1. 什么是关系数据库设计?答:关系数据库设计是指根据实际需求,设计数据库的结构和模式。
数据库实用教程 董健全 丁宝康 编著 清华大学出版社第5章

2.函数依赖是语义范畴的概念。
我们只能根据语义来确定一个函数依赖,而不能按照 其形式化定义来证明一个函数依赖是否成立。 例如,对于关系模式S (SNO,SNAME,AGE,DEPT) ,当 学生不存在重名的情况下,可以得到:
SNAME→AGE SNAME→DEPT
这种函数依赖关系,必须是在没有重名的学 生条件下才成立的,否则就不存在函数依赖 了。 所以函数依赖反映了一种语义完整性约束。 3.函数依赖与属性之间的联系类型有关。 (1)在一个关系模式中,如果属性X与Y有 1:1联系时,则存在函数依赖X→Y,Y→X,即 X Y。
但是将R分解成R1和R2两个模式是否最佳 分解,也不是绝对的。如果要查询学生所学课 程的任课教师,就要对两个关系做联接操作, 而联接的代价是很大的。而在原来模式R 的关 系中,就可直接找到上述结果。到底什么样的 关系模式是最优的?标准是什么?如何实现? 都是本章要讨论的问题。
5.1.4 本章的符号规定
关系数据库的规范化理论主要包括三个方面的 内容:
函数依赖 范式(Normal Form) 模式设计
其中,函数依赖起着核心的作用,是模式分解 和模式设计的基础,范式是模式分解的标准。
5.1.2 关系模型的外延和内涵
一个关系模型包括外延(Extension)和内 涵(Intension)两个方面的内容
这里t[X]表示元组t在属性集X上的值,其 余类同。XY读作“X函数决定Y”,或“Y函数 依赖于X”。FD是对关系模式R的一切可能的关 系r定义的。
对于当前关系r的任意两个元组,如果X值 相同,则要求Y值也相同,即有一个X值就有一 个Y值与之对应,或者说Y值由X值决定。因而 这种依赖称为函数依赖。 这类似于变量之间的单值函数关系。设单值 函数Y=F(X),自变量X的值可以决定一个唯一 的函数值Y 等价定义1:在r中不存在两个元组,在X上的 值相同,在Y上的值却不同。 等价定义2:若两个元组在Y上的值不同,则 在X上的值也不同。(逆否命题)
数据库系统教程(第三版课后答案)免费下载.doc
第1章数据库概论1.1 基本内容分析1.1.1 本章的重要概念(1)DB、DBMS和DBS的定义(2)数据管理技术的发展阶段人工管理阶段、文件系统阶段、数据库系统阶段和高级数据库技术阶段等各阶段的特点。
(3)数据描述概念设计、逻辑设计和物理设计等各阶段中数据描述的术语,概念设计中实体间二元联系的描述(1:1,1:N,M:N)。
(4)数据模型数据模型的定义,两类数据模型,逻辑模型的形式定义,ER模型,层次模型、网状模型、关系模型和面向对象模型的数据结构以及联系的实现方式。
(5)DB的体系结构三级结构,两级映像,两级数据独立性,体系结构各个层次中记录的联系。
(6)DBMSDBMS的工作模式、主要功能和模块组成。
(7)DBSDBS的组成,DBA,DBS的全局结构,DBS结构的分类。
1.1.2本章的重点篇幅(1)教材P23的图1.24(四种逻辑数据模型的比较)。
(2)教材P25的图1.27(DB的体系结构)。
(3)教材P28的图1.29(DBMS的工作模式)。
(4)教材P33的图1.31(DBS的全局结构)。
1.2 教材中习题1的解答1.1 名词解释·逻辑数据:指程序员或用户用以操作的数据形式。
·物理数据:指存储设备上存储的数据。
·联系的元数:与一个联系有关的实体集个数,称为联系的元数。
·1:1联系:如果实体集E1中每个实体至多和实体集E2中的一个实体有联系,反之亦然,那么E1和E2的联系称为“1:1联系”。
·1:N联系:如果实体集E1中每个实体可以与实体集E2中任意个(零个或多个)实体有联系,而E2中每个实体至多和E1中一个实体有联系,那么E1和E2的联系是“1:N联系”。
·M:N联系:如果实体集E1中每个实体可以与实体集E2中任意个(零个或多个)实体有联系,反之亦然,那么E1和E2的联系称为“M:N联系”。
·数据模型:能表示实体类型及实体间联系的模型称为“数据模型”。
(完整版)数据库系统基础教程第五章答案
Exercise 5.1.1 As a set:speed2.662.101.422.803.202.202.001.863.06 Average = 2.37 As a bag:speed2.662.101.422.803.203.202.202.202.002.801.862.803.06 Average = 2.48 Exercise 5.1.2 As a set:hd25080320200300160 Average = 218 As a bag:hd2502508025025032020025025030016016080 Average = 215 Exercise 5.1.3a As a set:bore15161418As a bag:bore1516141615151418Exercise 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 D or 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.A+B A2B210154910164167916 Exercise 5.2.1bB+1C-1103334431143 Exercise 5.2.1cA B0101232434 Exercise 5.2.1dB C010224253434A B01232434 Exercise 5.2.1fB C0124253402 Exercise 5.2.1gA SUM(B)022734 Exercise 5.2.1hB AVG(C)0 1.52 4.534 Exercise 5.2.1iA23Exercise 5.2.1jA MAX(C)24 Exercise 5.2.1kA B C23423401┴01┴24┴34┴Exercise 5.2.1lA B C234234┴01┴24┴25┴02 Exercise 5.2.1mA B C23423401┴01┴24┴34┴┴01┴24┴25┴02Exercise 5.2.1nA R.B S.B C0124012501340134012401250134013423┴┴24┴┴34┴┴┴┴01┴┴02Exercise 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(model,_,_,_,_,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,model2,_) 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) ← FastestComputers(model) AND Product(maker,model,_) j)PCs(maker,speed) ← PC(model,speed,_,_,_) AND Product(maker,model,_) Answer(maker) ← PCs(maker,speed) AND PCs(maker,speed1) ANDPCs(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,_,launched) 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(name,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)MoreThanOne(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.3Answer(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,sz) ← 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 = syAnswer(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)。
数据库原理及应用教程第3版课后题答案
第一章习题参考答案一、选择题1. C2. B3. D4. C5. D6. A7. A8. B9. D 10. B11. C 12. D 13. A 14. D 15. B16. C 17. D 18. A 19. D 20. A二、填空题1. 数据库系统阶段2. 关系3. 物理独立性4. 操作系统5. 数据库管理系统(DBMS)6. 一对多7. 独立性8. 完整性控制9. 逻辑独立性10. 关系模型11. 概念结构(逻辑)12. 树有向图二维表嵌套和递归13. 宿主语言(或主语言)14. 数据字典15. 单用户结构主从式结构分布式结构客户/服务器结构浏览器/服务器结构第2章习题参考答案一、选择题1. A2. C3. C4. B5. B6. C7. B8. D9. C 10. A11. B 12. A 13. A 14. D 15. D二、填空题1. 选择(选取)2. 交3. 相容(或是同类关系)4. 并差笛卡尔积选择投影5. 并差交笛卡尔积6. 选择投影连接7. σf(R)8. 关系代数关系演算9. 属性10. 同质11. 参照完整性12. 系编号,系名称,电话办公地点13. 元组关系域关系14. 主键外部关系键15. R和S没有公共的属性第3章习题参考答案一、选择题1. B2. A3. C4. B5. C6. C7. B8. D9. A 10. D二、填空题结构化查询语言(Structured Query Language)数据查询、数据定义、数据操纵、数据控制外模式、模式、内模式数据库、事务日志NULL/NOT NULL、UNIQUE约束、PRIMARY KEY约束、FOREIGN KEY约束、CHECK 约束聚集索引、非聚集索引连接字段行数定义系统权限、对象权限基本表、视图12.(1)INSERT INTO S VALUES('990010','李国栋','男',19)(2)INSERT INTO S(No,Name) VALUES('990011', '王大友')(3)UPDATE S SET Name='陈平' WHERE No='990009'(4)DELETE FROM S WHERE No='990008'(5)DELETE FROM S WHERE Name LIKE '陈%'13.CHAR(8) NOT NULL14.o=o15.ALTER TABLE StudentADDSGrade CHAR(10)第4章习题参考答案一、选择题1. B2. B3. D4. B5. C6. D7. B8. D9. C 10. A二、填空题1. 超键(或超码)2. 正确完备3. 属性集X的闭包X + 函数依赖集F的闭包F +4. 平凡的函数依赖自反性5. {AD→C} φ6. 2NF 3NF BCNF7. 无损连接保持函数依赖8. AB BC BD9. B→φ B→B B→C B→BC10. B→C A→D D→C11. AB 1NF12. AD 3NF第5章习题参考答案一、选择题1. B2. B3. C4. A5. C6. D7. A8. C9. D 10. D11. B 12. B 13. A 14. D 15. A二、填空题安全性控制、完整性控制、并发性控制、数据库恢复数据对象、操作类型授权粒度、授权表中允许的登记项的范围原始数据(或明文)、不可直接识别的格式(或密文)、密文事务、原子性、一致性、隔离性、持久性丢失更新、污读、不可重读封锁、排它型封锁、共享封锁利用数据的冗余登记日志文件、数据转储事务故障、系统故障、介质故障完整性登录账号、用户账号public服务器、数据库第6章习题参考答案一、选择题1. B2. C3. C4. A5. C6. B7. C8. B9. D 10. C11. D 12. B 13. B 14. D二、填空题数据库的结构设计、数据库的行为设计新奥尔良法分析和设计阶段、实现和运行阶段需求分析概念结构设计自顶向下、自底向上属性冲突、命名冲突、结构冲突逻辑结构设计确定物理结构、评价物理结构数据库加载运行和维护物理数据字典需求分析载入第7章习题参考答案一、选择题1. B2.C3.B4.D5.A二、填空题局部变量、全局变量- -、/*……*/DECLARESQL、流程控制AFTER 触发器、INSTEAD OF 触发器插入表、删除表数据库备份、事务日志备份、差异备份、文件和文件组备份简单还原、完全还原、批日志还原硬盘、磁带、管道下面是古文鉴赏,不需要的朋友可以下载后编辑删除!!谢谢!!九歌·湘君屈原朗诵:路英君不行兮夷犹,蹇谁留兮中洲。
数据库原理及应用教程第三版课后答案
数据库原理及应用教程第三版课后答案1. 数据库原理概述。
数据库是指按照数据结构来组织、存储和管理数据的仓库,它是存储数据的集合,是数据按照一定的数据模型组织、描述和存储的仓库。
数据库原理是指数据库的基本概念、基本理论和基本方法。
数据库原理主要包括数据库的基本概念、数据库的基本结构、数据库的基本操作、数据库的基本设计和数据库的完整性、安全性等方面的内容。
2. 数据库应用教程第三版课后答案。
2.1 数据库原理基础知识。
数据库原理是数据库领域的基础理论,它主要包括数据模型、数据库结构、数据库设计、数据库语言和数据库管理系统等内容。
数据库原理是数据库应用的基础,它的学习对于理解数据库的工作原理和实际应用具有重要意义。
2.2 数据库原理及应用教程第三版课后答案。
1) 数据库的基本概念包括数据、数据库、数据库管理系统、数据库系统和数据库技术等内容。
2) 数据库的基本结构包括数据模型、数据结构、数据操作和数据完整性等内容。
3) 数据库的基本操作包括数据的插入、删除、修改和查询等内容。
4) 数据库的基本设计包括数据库的逻辑设计和物理设计等内容。
5) 数据库的完整性和安全性包括数据的完整性约束和安全性约束等内容。
2.3 数据库应用教程第三版课后答案。
数据库应用教程第三版的课后答案主要包括数据库的基本概念、数据库的基本结构、数据库的基本操作、数据库的基本设计和数据库的完整性、安全性等方面的内容。
通过学习这些课后答案,可以加深对数据库原理及应用的理解,提高对数据库的应用能力。
3. 数据库原理及应用教程第三版课后答案的重要性。
数据库原理及应用教程第三版课后答案是数据库课程的重要组成部分,它可以帮助学生巩固课堂上所学到的知识,加深对数据库原理及应用的理解。
通过做课后习题,可以检验学生对数据库知识的掌握程度,帮助他们发现和解决学习中存在的问题。
同时,课后答案还可以为教师提供教学参考,指导教学工作。
4. 结语。
数据库原理及应用教程第三版课后答案是数据库课程的重要组成部分,它对于学生巩固知识、提高应用能力具有重要意义。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
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→ABCD
5.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有三个:
(职工名,项目名)→工资
项目名→部门名
部门名→部门经理
关键码为(职工名,项目名)。
⑵根据⑴,R中存在下列两个FD:
(职工名,项目名)→(部门名,部门经理)
项目名→(部门名,部门经理)
其中前一个FD是一个局部依赖,因此R不是2NF模式。
R应分解成两个模式:
R1(项目名,部门名,部门经理)R2(职工名,项目名,工资)R1和R2都是2NF 模式。
⑶R2已是3NF模式。
在R1中,由于存在两个FD:
项目名→部门名部门名→部门经理
即存在一个传递依赖,因此R1不是3NF模式。
对R1应分解成两个模式:R11(职工名,部门名),R12(部门名,部门经理)。
这两个模式都是3NF模式。
因此,R分解成3NF模式集时,ρ={R11,R12,R2}。
5.9关系模式R分解成ρ={R1,…,Rk},F是R上的一个FD集,那么R中满足F
的每一个关系r,与其投影联接表达式mρ(r)间的关系满足r伜mρ(r)。
5.10设关系模式R(A,B,C),F是R上成立的FD集,F={B→A,B→C},则分解ρ={AB,AC}丢失的FD是B→C。
5.11设关系模式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.12设有关系模式R(A,B,C,D),F是R上成立的FD集,F={D→A,D→B},试写出关系模式R的候选键,并说明理由。
答:①R的候选键是CD
②理由:从已知的F,可导出D→ABD,再根据增广律,可得出CD→ABCD,即CD 值可决定全部属性值。
5.13消除了每个属性对候选键传递依赖的关系模式,称为BCNF模式。
5.14在关系模式的分解中,数据等价用(无损分解)衡量。
5.15设关系模式R(SNO,CNO,GRADE,TNAME,TADDR),其属性分别表示学生学号、选修课的编号、成绩、任课教师姓名、教师地址等意义。
如果规定,每个学生每学一门课只有一个成绩;每门课只有一个教师任教;每个教师只有一个地址(此处不允许教师同名)。
(1)试写出关系模式R基本的函数依赖和候选键。
(2)试把R分解成3NF模式集,并说明理由。
解:(1)F={(SNO,CNO)→GRADE,CNO→TNAME,TNAME→TADDR}关系模式的侯选键是S#,C#。
(2)可分解为下列三个关系。
SC={SNO,CNO,GRADE}C={CNO,TNAME,TADDR}
理由如下:在原模式R中,TNAME不完全依赖于键(SNO,CNO),因此需进行分解,分解后,SC中,GRADE完全依赖于(SNO,CNO),在C中,主属性是CNO,其他非主属性均完全依赖于CNO。
因此这个分解是正确的。