数据库系统基础教程第三章答案_第1页
数据库系统基础教程第三章答案_第2页
数据库系统基础教程第三章答案_第3页
已阅读5页,还剩29页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Exercise Answers for this exercise may vary because of different interpretations.Some possible FDs:Social Security number Area codestateStreet address, city, statenamezipcodePossible keys:Social Security number, street address, city, state, area code, phone numberNeed street address, city, state to

2、uniquely determine location. A person could have multiple addresses. The same is true for phones. These days, a person could have a landline and a cellular phoneExercise Answers for this exercise may vary because of different interpretationsSome possible FDs:IDx-position, y-position, z-positionIDx-v

3、elocity, y-velocity, z-velocityx-position, y-position, z-positionIDPossible keys:IDx-position, y-position, z-positionThe reason why the positions would be a key is no two molecules can occupy the same point.The superkeys are any subset that contains A each of the n-1 attributes A 2 through A(n-1)1.

4、Thus, there are 2such subsets, sincen may independently be chosen in or out.The superkeys are any subset that contains A considering A 1 and the n-1 attributes A considering A 2 and the n-2 attributes A1 or A 2. There are 2 (n-1) such subsets when(n-2)2 through A n. There are 2 such subsets when3 th

5、rough A n. We do not count A 1 in these subsets because they are already counted in the first group of subsets. The total number of subsets is 2 (n-1) + 2 (n-2) .The superkeys are any subset that contains A1,A 2 or A 3,A 4. There are 2such subsetswhen considering A 小2 and the n-2 attributes A3 throu

6、gh A n. There are 2(n-2) 2 (n-4) suchsubsets when considering A 3,A4 and attributes A5 through A n along with the individualattributes A 1 and A 2. We get the 2(n-4) term because we have to discard the subsets thatcontain the key A1,A2 to avoid double counting. The total number of subsets is 2(n-2)

7、+2(n-2)_ 2(n-4)The superkeys are any subset that contains A1,A2or A 1,A3. There are 2(n-2)suchsubsetswhen considering A 1,A2 and the n-2 attributes A3throughA n. There are 2(n-3)suchsubsetswhen considering A 1,A3 and the n-3 attributes A4throughA n We do not count A 2 in thesesubsets because they ar

8、e already counted in the first group ofsubsets. The total numberof subsets is 2 (n-2) + 2 (n-3) .We could try inference rules to deduce new dependencies until we are satisfied we have them all. A more systematic way is to consider the closures of all 15 nonempty sets of attributes.For the single att

9、ributes we have A+ = A, B+ = B, C+ = ACD, and D+ = AD. Thus, theonly new dependency we get with a single attribute on the left is CA.Now consider pairs of attributes:AB + = ABCD, so we get new dependency AB D. AC + = ACD, and AC D is nontrivial. AD = AD, so nothing new. BC + = ABCD, so we get BC A,

10、and BC D. BD + = ABCD, giving us BD A and BD C. CD + = ACD, giving CD A.+For the triples of attributes, ACD= ACD, but the closures of the other sets are eachABCD. Thus, we get new dependencies ABC D, ABD C, and BCD A.Since ABCD + = ABCD, we get no new dependencies.The collection of 11 new dependenci

11、es mentioned above are:C A, AB D, AC D, BC A, BC D, BD A, BD C, CD A, ABC D, ABD C, and BCD A.From the analysis of closures above, we find that AB, BC, and BD are keys. All other sets either do not have ABCD as the closure or contain one of these three sets.The superkeys are all those that contain o

12、ne of those three keys. That is, a superkey that is not a key must contain B and more than one of A, C, and D. Thus, the (proper) superkeys are ABC, ABD, BCD, and ABCD.i) For the single attributes we have A+ = ABCD, B + = BCD, C + = C, and D + = D. Thus,the new dependencies are AC and A D.Now consid

13、er pairs of attributes:AB+ = ABCD, AC + = ABCD, AD + = ABCD, BC + = BCD, BD + = BCD, CD + = CD. Thus the new dependencies are AB C, AB D, AC B, AC D, AD B, AD C, BC D and BD C.For the triples of attributes, BCDD, ABD C, and ACD B.= BCD, but the closures of the other sets are eachABCD. Thus, we get n

14、ew dependencies ABCSince ABCD + = ABCD, we get no new dependencies.The collection of 13 new dependencies mentioned above are:A C, A D, AB C, AB D, AC B, AC D, AD ACD B.ii) For the single attributes we have A+there are no new dependencies.B, AD C, BC D, BD C, ABC D, ABD C and= A, B + = B, C + = C, an

15、d D + = D. Thus,Now consider pairs of attributes:AB+ = ABCD, AC + = AC, AD + = ABCD, BC + = ABCD, BD + = BD, CD + = ABCD. Thus the new dependencies are ABD, AD C, BC A and CD B.For the triples of attributes, all the closures of the sets are each ABCD. Thus, we get new dependencies ABC D, ABD C, ACD

16、B and BCD A.+Since ABCD = ABCD, we get no new dependencies.The collection of 8 new dependencies mentioned above are:AB D, AD C, BC A, CD B, ABC D, ABD C, ACD B and BCD A.iii) For the single attributes we have A ABCD. Thus, the new dependencies are A+ = ABCD, B + = ABCD, C + = ABCD, and D + = C, A D,

17、 B D, B A, C A, C B, D B and D C.Since all the single attributes' closures are ABCD, any superset of the singleattributes will also lead to a closure of ABCD. Knowing this, we can enumerate the rest of the new dependencies.The collection of 24 new dependencies mentioned above are:A C, A D, B D,

18、B A, C A, C B, D B, D C, AB C, AB D, AC B, AC D, AD B, AD C, BC A, BC D, BD A, BD C, CD A, CD B, ABC D, ABD C, ACD B and BCD A.i)ii)iii)iii)Si nee A 1A2 AC con tai ns A 4 An, then the closure of A1AAnC contains B. Thus it followsthat A 1A2 AnC B.1A2AnC B. Using the concept of trivial dependencies, w

19、e canshow that A 1A2AnC C. Thus A 1A2 AnC BC.1B2 Bm because of the FD A1A2 An1C2 Ck. Thus the closure ofD.1B2 Bm because of the FD A1A2 An1A2 AGG C con tai ns D 1C2 D. Thus,From A1A2代巳匕E , we know that the closure contains BBB2Bm The B 1B2Bm and the E 1E2E combine to form the C AA2 AnEE Ej con tai n

20、s D as well. Thus, A1A2 AE1E2 EFrom A1A2 AnCiC2 C, we kn ow that the closure con tai ns B B B2Bm The C 1C2C< also tell us that the closure of A AA2AnCiC2Ck BiB>B<DDD.If attribute A represented Social Security Number and B represented a person' s name,then we would assume A B but B A wou

21、ld not be valid because there may be many people with the same name and different Social Security Numbers.Let attribute A represent Social Security Number, B represent gender and C represent name.Surely Social Security Number and gender can uniquely identify a person ' s name (i.e. AB C). A Soci

22、al Security Number can also uniquely identify a person ' s name (i.e. A C). However, gender does not uniquely determine a name (i.e. B C is not valid).Let attribute A represent latitude and B represent longitude. Together, both attributescan uniquely determine C, a point on the world map (i.e. A

23、B C). However, neither A nor B can uniquely identify a point (i.e. A C and B C are not valid).Exercise Give n a relati on with attributes AAAn, we are told that there are no fun ctio naldependencies of the form BiE2B-i C where B iBB-i is n-1 of the attributes from A1A2Aand C is the remaining attribu

24、te from A1A2An. In this case, the set B1庄B>1 and anysubset do not functionally determine C. Thus the only functional dependencies that we can make are ones where C is on both the left and right hand sides. All of these functional dependencies would be trivial and thus the relation has no nontrivi

25、al FD's.Let's prove this by using the contrapositive. We wish to show that if X+ is not a subsetof Y +, then it must be that X is not a subset of Y.If X + is not a subset of Y+, there must be attributes A1A2A in X + that are notin Y+. Ifany of these attributes were originally in X, then we a

26、re done because Y does not contain any of the A 1A2A. However, if the A iAA were added by the closure, then we must examine the case further. Assume that there was some FD C1C2Cm A1A2A where A 1A2A issome subset of AiAe A. It must be then that CiGCm or some subset of C1C2 Cm is in X.However, the att

27、ributes C1C2Cm cannot be in Y because we assumed that attributes A1A2A+are only in X and are not in Y . Thus, X is not a subset of Y.+By proving the contrapositive, we have also proved if X? Y, then X ? Y .+The algorithm to find Xis outlined on pg. 76. Using that algorithm, we can prove that(X+)+ =

28、X+. We will do this by using a proof by contradiction.+ + + + +Suppose that (X ) MX. Then for (X ) , it must be that some FD allowed additional attributes to be added to the original set X+. For example, X + A where A is someattribute not in X+. However, if this were the case, then X+ would not be t

29、he closure of X.The closure of X would have to include A as well. This contradicts the fact that we weregiven the closure of X, X closure of X. Therefore, it must be that (X) = X or else X is not theIf all sets of attributes are closed, then there cannot be any nontrivial functionaldependencies. Sup

30、pose A 1A2.A n B is a nontrivial dependency. Then A1A2.A n + contains Band thus A 1A2.A n is not closed.and A,B,C,D, then the following FDs hold:ABACADBABCBDCACBCDDADBDCABCABDACBACDADBADCBCABCDBDABDCCDACDBIf the only closed sets areABC DABD CACD BBCD AIf the only closed sets areA,B and A,B,C,D, then

31、 the following FDs hold:ABBAC AC BC DD AD BD CACBACDADBADCBCABCDBDABDCCDACDBABCDABDCACDBBCDAExercise We can think of this problem as a situation where the attributes A,B,C represent cities and the functional dependencies represent one way paths between the cities. The minimal bases are the minimal n

32、umber of pathways that are needed to connect the cities. We do not want to create another roadway if the two cities are already connected.The systematic way to do this would be to check all possible sets of the pathways. However, we can simplify the situation by noting that it takes more than two pa

33、thways to visit the two other cities and come back. Also, if we find a set of pathways that is minimal, adding additional pathways will not create another minimal set.The two sets of minimal bases that were given in example 3.11 are:A B, B C, C AA B, B A, B C, C BThe additional sets of minimal bases

34、 are:CB, BA, ACAB, AC, BA, CAAC, BC, CA, CBWe need to compute the closures of all subsets of ABC, although there is no need to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets:A +=AB +=B+C +=ACEAB +=ABCDE+AC +=ACEBC +=ABCDEWe ignore D

35、 and E, so a basis for the resulting functional dependencies for ABC is: CAand AB C. Note that BC->A is true, but follows logically from C->A, and therefore may be omitted from our list.We need to compute the closures of all subsets of ABC, although there is no need to think about the empty se

36、t or the set of all three attributes. Here are the calculations for the remaining six sets:A +=ADB +=BC +=CAB +=ABDEAC =ABCDEBC +=BCWe ignore D and E, so a basis for the resulting functional dependencies for ABC is: ACB.We need to compute the closures of all subsets of ABC, although there is no need

37、 to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets:A +=AB +=BC +=CAB +=ABDAC +=ABCDEBC +=ABCDEWe ignore D and E, so a basis for the resulting functional dependencies for ABC is: ACBand BC A.We need to compute the closures of all sub

38、sets of ABC, although there is no need to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets:A +=ABCDEB +=ABCDEC +=ABCDEAB +=ABCDE+AC +=ABCDEBC +=ABCDEWe ignore D and E, so a basis for the resulting functional dependencies for ABC is: A

39、B,B C and C A.Exercise For step one of Algorithm 3.7, suppose we have the FD ABCDE. We want to use Armstrongs Axioms to show that ABCD and ABC E follow. Surely the functional dependencies DEDE and DE D. Likewise, E.and DE E hold because they are trivial and follow the reflexivity property. Using the

40、 transitivity rule, we can derive the FD ABCD from the FDs ABCwe can do the same for ABCDE and DE E and derive the FD ABCD and D E. According D and augmenting bothFor steps two through four of Algorithm 3.7, suppose we have the initial set of attributes of the closure as ABC. Suppose also that we ha

41、ve FDs C to Algorithm 3.7, the closure should become ABCDE. Taking the FD C sides with attributes AB we get the FD ABCABD. We can use the splitting method in stepone to get the FD ABCD. Since D is not in the closure, we can add attribute D. Takingthe FD D E and augmenting both sides with attributes

42、ABC we get the FD ABCDABCDE.Using again the splitting method in step one we get the FD ABCDE. Since E is not in theclosure, we can add attribute E.Given a set of FDs, we can prove that a FD F follows by taking the closure of the left side of FD F. The steps to compute the closure in Algorithm 3.7 ca

43、n be mimicked by Armstrong ' s axioms and thus we can prove F from the given set of FDs using Armstrong' saxioms.In the solution to Exercise we found that there are 14 nontrivial dependencies, including the three given ones and eleven derived dependencies. They are: CA, C D,D A, AB D, AB C,

44、AC D, BC A, BC D, BD A, BD C, CD A, ABC D, ABD C, and BCD A.We also learned that the three keys were AB, BC, and BD. Thus, any dependency above that does not have one of these pairs on the left is a BCNF violation. These are: CA, C D,D A, AC D, and CD A.One choice is to decompose using the violation

45、 CD. Using the above FDs, we get ACD andBC as decomposed relations. BC is surely in BCNF, since any two-attribute relation is.Using Algorithm 3.12 to discover the projection of FDs on relation ACD, we discover that ACD is not in BCNF since C is its only key. However, DA is a dependency that holds in

46、ABCD and therefore holds in ACD. We must further decompose ACD into AD and CD. Thus, the three relations of the decomposition are BC, AD, and CD.By computing the closures of all 15 nonempty subsets of ABCD, we can find all the nontrivial FDs. They are BC, B D, AB C, AB D, BC D, BD C, ABC D and ABD C

47、. Fromthe closures we can also deduce that the only key is AB. Thus, any dependency above that does not contain AB on the left is a BCNF violation. These are: BC, B D, BC D andBD C.One choice is to decompose using the violation BC. Using the above FDs, we get BCD andAB as decomposed relations. AB is

48、 surely in BCNF, since any two-attribute relation is.Using Algorithm 3.12 to discover the projection of FDs on relation BCD, we discover that BCD is in BCNF since B is its only key and the projected FDs all have B on the left side.Thus the two relations of the decomposition are AB and BCD.12 nontriv

49、ial dependencies, including the four given ones and the eight derived ones. They are ABC, BC D, CD A,AD B, AB D, AD C, BC A, CD B, ABC D, ABD C, ACD B and BCD A.We also found out that the keys are AB, AD, BC, and CD. Thus, any dependency above that does not have one of these pairs on the left is a B

50、CNF violation. However, all of the FDs contain a key on the left so there are no BCNF violations.No decomposition is necessary since all the FDs do not violate BCNF.28 nontrivialB, B C,B, AC D,dependencies, including the four given ones and the 24 derived ones. They are AC D, D A, A C, A D, B D, B A

51、, C A, C B, D B, D C, AB C, AB D, ACAD B, AD C, BC A, BC D, BD A, BD C, CD A, CDB, ABC D, ABD C, ACDB and BCD A.We also found out that the keys are A,B,C,D. Thus, any dependency above that does not have one of these attributes on the left is a BCNF violation. However, all of the FDs contain a key on

52、 the left so there are no BCNF violations.No decomposition is necessary since all the FDs do not violate BCNF.C,C,By computing the closures of all 31 nonempty subsets of ABCDE, we can find all the nontrivial FDs. They are AB C, DE C, B D, AB D, BC D, BE C, BE D, ABC D, ABD ABE C, ABE D, ADE C, BCE D

53、, BDE C, ABCE D, and ABDE C. From the closures we can also deduce that the only key is ABE. Thus, any dependency above that does not containABE on the left is a BCNF violation. These are: ABC, DE C, B D, AB D, BC D, BEBE D, ABC D, ABD C, ADE C, BCE D and BDE C.One choice is to decompose using the vi

54、olation ABC. Using the above FDs, we get ABCDand ABE as decomposed relations. Using Algorithm 3.12 to discover the projection of FDs on relation ABCD, we discover that ABCD is not in BCNF since AB is its only key and the FD B D follows for ABCD. Using violation BD to further decompose, we get BD and

55、 ABC asdecomposed relations. BD is in BCNF because it is a two-attribute relation. UsingAlgorithm 3.12 again, we discover that ABC is in BCNF since AB is the only key and ABCis the only nontrivial FD. Going back to relation ABE, following Algorithm 3.12 tells us that ABE is in BCNF because there are

56、 no keys and no nontrivial FDs. Thus the threerelations of the decomposition are ABC, BD and ABE.By computing the closures of all 31 nonempty subsets of ABCDE, we can find all thenontrivial FDs. They are: C B, C D, C E, D B, D E, AB C, AB D, AB E, AC B, AC D, AC E, AD B, AD C, AD E, BC D, BC E, BD E, CD B, CD E, CE B,

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论