《Database System Concepts(数据库系统概念)》第六版——第八次作业(第八章)

8.4

若 α → β , α → γ 则 α → α β ( 增广律: α α → α β ) , α β → γ β ( 增广律 ) 则 α → γ β ( 传递律 ) 若\alpha \rightarrow \beta,\alpha \rightarrow \gamma \\则\alpha \rightarrow \alpha\beta(增广律:\alpha\alpha \rightarrow\alpha\beta),\alpha \beta \rightarrow \gamma\beta(增广律) \\则\alpha \rightarrow \gamma\beta(传递律) αβ,αγααβ(增广律:αααβ),αβγβ(增广律)αγβ(传递律)

8.5

若 α → β , γ β → δ 则 γ α → γ β ( 增广律 ) 则 γ α → δ ( 传递律 ) 若\alpha \rightarrow \beta,\gamma\beta \rightarrow \delta \\则\gamma\alpha \rightarrow \gamma\beta(增广律) \\则\gamma\alpha \rightarrow \delta(传递律) αβ,γβδγαγβ(增广律)γαδ(传递律)

8.6

A → B C , B → D , 故 A → B C D C D → E , 故 A → A B C D E E → A , 故 E → A B C D E C D → E , 故 C D → A B C D E C D → E , B → D , 故 B C → E , B C → A B C D E A\rightarrow BC,B\rightarrow D,故A\rightarrow BCD \\CD\rightarrow E,故A\rightarrow ABCDE \\E\rightarrow A,故E\rightarrow ABCDE \\CD\rightarrow E,故CD \rightarrow ABCDE \\CD\rightarrow E,B\rightarrow D, 故BC\rightarrow E,BC\rightarrow ABCDE ABC,BD,ABCDCDE,AABCDEEA,EABCDECDE,CDABCDECDE,BD,BCE,BCABCDE

F + F^+ F+

A → A B C D E , B → B D , C → C , D → D , E → A B C D E , B C → A B C D E , C D → A B C D E , B D → B D , X → A B C D E ( X 为剩余元素集 ) A\rightarrow ABCDE,B\rightarrow BD,C\rightarrow C,D\rightarrow D,E\rightarrow ABCDE ,\\BC\rightarrow ABCDE,CD\rightarrow ABCDE,BD\rightarrow BD, \\X\rightarrow ABCDE(X为剩余元素集) AABCDE,BBD,CC,DD,EABCDE,BCABCDE,CDABCDE,BDBD,XABCDE(X为剩余元素集)

候选码为 A , E , B C , C D A,E,BC,CD A,E,BC,CD

8.7

对于给出的F:任何函数依赖都不含无关属性,左半部唯一

故F即是Fc

8.8

  • 设|F|=n,元素个数为m

    由图8-8算法的叙述可知其复杂性为O( n 2 n^2 n2)

    图8-18的算法第一次循环了n次,第二次循环循环了nm次,addin(a)的循坏只对a进行操作,循坏次数为a的属性个数乘以n,不超过nm次,故此算法复杂性为O(nm)

    最坏情况下, n = 2 m ∗ 2 m = 4 m n=2^m*2^m=4^m n=2m2m=4m,

    故O(nm)的算法比O( n 2 n^2 n2)高效

  • 在第一步中, A ⊆ α , α → A A\subseteq \alpha,\alpha\rightarrow A Aα,αA,A显然是result中的元素

    假设第k步正确, β → γ , β ⊆ r e s u l t , γ ⊆ r e s u l t \beta\rightarrow\gamma,\beta\subseteq result,\gamma\subseteq result βγ,βresult,γresult

    在第k+1步中, A ⊆ γ , γ → A A\subseteq \gamma,\gamma\rightarrow A Aγ,γA,A显然是result中的元素

    故算法得到的result中均是 a + a^+ a+的元素

    而如果存在 a + a^+ a+的属性不属于result

    则必定存在 β → γ , β ⊆ r e s u l t \beta\rightarrow\gamma,\beta\subseteq result βγ,βresult γ \gamma γ至少有一个属性不在result中(设为A)

    当算法结束时,A已添加到result当中

    综上,该算法正确性得证

8.11

  • a

    约束为: α 是 r 1 的主码, α 是 r 2 参考 r 1 的外码 约束为:\alpha是r_1的主码,\alpha是r_2参考r_1的外码 约束为:αr1的主码,αr2参考r1的外码

  • b

    e g : 对于某个 r ( 1 , 2 , 3 ) , 分解后 r 1 ( 1 , 2 ) , r 2 ( 1 , 3 ) , 若不添加外码约束则 r 2 可更新为 ( 4 , 3 ) ,而 r 1 不变 eg:对于某个r(1,2,3),分解后r_{1}(1,2),r_{2}(1,3),若不添加外码约束则r_2可更新为(4,3),而r_1不变 eg:对于某个r(1,2,3),分解后r1(1,2),r2(1,3),若不添加外码约束则r2可更新为(4,3),而r1不变

  • c

    对于每个 R i , α → β , α 是主码;因为 3 N F 分解的函数依赖集是 F c , 故 R i 主码均不同,对于 R j 的某个属性集 α 若是 R i 的主码,则需作为 R j 参考 R i 的外码 对于每个R_i,\alpha\rightarrow \beta,\alpha是主码;因为3NF分解的函数依赖集是F_c,故R_i主码均不同,对于R_j的某个属性集\alpha若是R_i的主码,则需作为R_j参考R_i的外码 对于每个Ri,αβ,α是主码;因为3NF分解的函数依赖集是Fc,Ri主码均不同,对于Rj的某个属性集α若是Ri的主码,则需作为Rj参考Ri的外码

8.13

对于 B → D , 令 r e s u l t = B 对于B\rightarrow D,令result=B 对于BD,result=B

对于 R 1 , t = ( r e s u l t ∩ R 1 ) + ∩ R 1 = B + ∩ R 1 = B 对于R_1,t=(result\cap R_1)^+\cap R_1=B^+\cap R_1=B 对于R1,t=(resultR1)+R1=B+R1=B

r e s u l t = r e s u l t ∪ t = B result=result\cup t=B result=resultt=B

循环后 r e s u l t 还是 B 无变化,且不含 D ,故不是保持依赖 循环后result还是B无变化,且不含D,故不是保持依赖 循环后result还是B无变化,且不含D,故不是保持依赖

8.28

考虑R的两个实例(1,2,3,4,5),(6,7,3,8,9),分解后变为(1,2,3)(3,4,5)和(6,7,3)(3,8,9)

自然连接后则会出现(1,2,3,4,5),(1,2,3,8,9)(6,7,3,8,9),(6,7,3,4,5)四个实例

故不是无损分解

8.29

  • a

    B→D,D→A,B→AD,A→BCD,BC→DE,B→ABCDE

    B + B^+ B+=ABCDE

  • b

    A→BCD,A→BC,BC→DE,A→BCDE,A→A,A→ABCDE

    AF→ABCDE,AF→F,AF→ABCDEF

    故AF是超码

  • c

    第一次循环,未发现可合并项;直接快进至寻找无关属性

    A→BCD,B→D可知D为A→BCD的无关属性

    故F=A→BC,BC→DE,B→D,D→A

    第二次循环,未发现可合并项;直接快进至寻找无关属性

    BC→DE,B→D可知D为BC→DE的无关属性

    故F=A→BC,BC→E,B→D,D→A

    第三次循环,未发现可合并项;直接快进至寻找无关属性

    BC→E,B→ABCDE,可知C为BC→E的无关属性

    故F=A→BC,B→E,B→D,D→A

    第四次循环,发现可合并项:B→DE

    无无关属性

    故F=A→BC,B→DE,D→A

    第五次循环,未发现可合并项和无关属性

    故Fc=A→BC,B→DE,D→A

  • d

    R 1 = ( A , B , C ) , R 2 = ( B , D , E ) , R 3 = ( D , A ) R_1=(A,B,C),R_2=(B,D,E),R_3=(D,A) R1=(A,B,C),R2=(B,D,E),R3=(D,A)

    候选码必含有F

    R i R_i Ri中均不含候选码,故加入 R 4 = ( A , F ) R_4=(A,F) R4=(A,F)

    模式间相互不包含

    故3NF分解为: R 1 = ( A , B , C ) , R 2 = ( B , D , E ) , R 3 = ( D , A ) , R 4 = ( A , F ) R_1=(A,B,C),R_2=(B,D,E),R_3=(D,A),R_4=(A,F) R1=(A,B,C),R2=(B,D,E),R3=(D,A),R4=(A,F)

  • e

    B + = A B C D E , A → B C D , D → A B^+=ABCDE,A→BCD,D→A B+=ABCDE,ABCD,DA

    A + = B + = ( B C ) + = D + = A B C D E A^+=B^+=(BC)^+= D^+=ABCDE A+=B+=(BC)+=D+=ABCDE

    候选码:AF,BF,DF

    result={R}

    违反BCNF的FD(左侧无码):A→BCD

    从A→BCD开始分解,result=(A,B,C,D)∪(A,E,F)

    (A,E,F)中候选码:AF

    违反BCNF的FD(左侧无码):A→E

    从A→BCD开始分解,result=(A,B,C,D)∪(A,E)∪(A,F)

    (A,B,C,D),(A,E),(A,F)均满足BCNF,故为r的BCNF分解

  • f

    F c = A → B C , B → D E , D → A Fc=A→BC,B→DE,D→A Fc=ABC,BDE,DA

    A + = B + = D + = A B C D E A^+=B^+= D^+=ABCDE A+=B+=D+=ABCDE

    候选码:AF,BF,DF

    result={R}

    违反BCNF的FD(左侧无码):A→BC

    从A→BC开始分解:result=(A,B,C)∪(A,D,E,F)

    (A,D,E,F)中的候选码:AF,DF

    违反BCNF的FD(左侧无码):A→DE

    从A→DE开始分解,result=(A,B,C)∪(A,D,E)∪(A,F)

    (A,B,C),(A,D,E),(A,F)均满足BCNF,故为Fc的BCNF分解,与e的分解不同

    综上,若直接运用算法,得到的BCNF分解与e的分解不同,但由Fc推出F的公式后再运用算法可得同样的分解

数据库系统概念(杨冬青)习题答案Chapter 1 provides a general overview of the nature and purpose of database systems. The most important concept in this chapter is that database systems allow data to be treated at a high level of abstraction. Thus, database systems differsignificantly from the file systemsand general purpose programming environments with which students are already familiar. Another important aspect of the chapter is to provide motivation for the use of database systems as opposed to application programs built on top of file systems. Thus, the chapter motivates what the student will be studying in the rest of the course. The idea of abstraction in database systems deserves emphasis throughout, not just in discussion of Section 1.3. The overview of the structure of databases is, of necessity, rather brief, and is meant only to give the student a rough idea of some of the concepts. The student may not initially be able to fully appreciate the concepts described here, but should be able to do so by the end of the course. The specifics of the E-R, relational, and object-oriented models are covered in later chapters. These models can be used in Chapter 1 to reinforce the concept of abstraction, with syntactic details deferred to later in the course. If students have already had a course in operating systems, it is worthwhile to point out how the OS and DBMS are related. It is useful also to differentiate between concurrency as it is taught in operating systems courses (with an orientation towardsfiles, processes,and physical resources)and database concurrency control (with an orientation towards granularity finer than the file level, recoverable transactions, and resources accessed associatively rather than physically). If students are familiar with a particular operating system, that OS’s approach to concurrent file access may be used for illustration.
第2章习题答案: 1. a) 数据定义语言(Data Definition Language,DDL)负责定义、修改和删除数据库的结构,如创建表、定义表的列、设定主键等操作。 b) 数据操作语言(Data Manipulation Language,DML)用于对数据库中的数据进行操作,如插入、查询、更新、删除等操作。 2. a) 关系模型(Relational Model)是一种用于组织数据的模型,它将数据组织为表格形式的关系,通过表格中的行和列来表示实体和属性之间的关系。 b) 实体-关系(Entity-Relationship)模型是一种用于描述现实世界中实体和它们之间关系的模型,通过实体、属性和联系的概念来表示。 3. 事务(Transaction)是指由一个或多个数据库操作组成的逻辑工作单位,它将数据库从一个一致状态转换到另一个一致状态。事务具有ACID属性,即原子性、一致性、隔离性和持久性。 4. 数据库系统的并发控制(Concurrency Control)是指在多个用户并发访问数据库时,保证数据的一致性和完整性的一系列技术和方法。常用的并发控制技术包括锁、并发控制算法和多版本并发控制。 5. a) 恢复(Recovery)是指在数据库系统发生故障时,通过一系列技术和方法将数据库从故障状态恢复到正常状态。 b) 日志(Log)是用于记录数据库操作的序列和重建数据的工具。常见的日志技术包括正向和反向恢复日志。 6. a) 数据库设计(Database Design)是指将现实世界的需求转化为数据库模式的过程,包括概念设计、逻辑设计和物理设计。 b) 数据库模式(Database Schema)是数据库的结构描述,包括表、列、键、约束等元素的定义。 7. a) 数据库安全(Database Security)是指保护数据库不被非法使用、不被篡改或窃取的一系列措施。常见的安全机制包括访问控制、身份验证和加密。 b) 数据库完整性(Database Integrity)是指保证数据库中数据的准确性和一致性的一系列约束和规则。常见的完整性约束包括主键、外键和检查约束。 8. a) 数据库视图(Database View)是基于数据库中一个或多个表的查询结果,以虚拟表的形式存储在数据库中,可以像访问普通表一样对其进行操作。 b) 数据库索引(Database Index)是用于提高数据检索性能的数据结构,通过按照某种规则将数据排序和组织起来,减少数据搜索的时间复杂度。 以上是对《数据库系统概念第六版第2章习题的回答。希望可以帮助到您!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值