简体   繁体   English

无损,依赖保持第三范式中关系的分解

[英]Lossless, dependency preserving decomposition of a relation in 3rd Normal Form

I am learning about normalization of databases and I came across the following problem: 我正在学习数据库的规范化,我遇到了以下问题:

 Given the following relation, BOSQID and its functional dependencies
 F={S->D, I->B, IS->Q, B->O},

How would I go about finding a lossless, dependency preserving decomposition of the above into 3rd normal form? 我将如何找到无损,依赖保持上述分解为第3范式?

Not really sure what 3rd normal form is, I looked it up and found the following requirements: 不太确定第3范式是什么,我查了一下,发现了以下要求:

1. The relation R (table) is in second normal form (2NF)

2. Every non-prime attribute of R is non-transitively dependent on every superkey of R.

After reading the above, I'm not too sure on where to begin. 看完上面的内容后,我不太清楚从哪里开始。 Also, not sure if it is helpful or relevant to answering the question, but I found the candidate key to be 此外,不确定回答问题是否有用或相关,但我找到了候选键

IS

If someone could point me in the right direction, I would greatly appreciate it. 如果有人能指出我正确的方向,我将非常感激。

We have a relation, R(BOSQID) and its functional dependencies: 我们有一个关系,R(BOSQID)及其功能依赖:

F={S→D, I→B, IS→Q, B→O} F = {S→D,I→B,IS→Q,B→O}

As, you have concluded that only {SI} is candidate key, since {SI}+ = SIDBQO=BOSQID and no subset of {SI} is computed all attributes of relation R. 因为,您已经得出结论,只有{SI}是候选键,因为{SI} + = SIDBQO = BOSQID并且没有计算{SI}的子集关系R的所有属性。

According to definition of partial dependency {S→D, I→B} are partial dependencies, since subset of candidate keys map non-prime attribute(s). 根据部分依赖性的定义{S→D,I→B}是部分依赖性,因为候选键的子集映射非素数属性。

According to 2NF, partial dependencies (ie, {S→D, I→B}) not allowed. 根据2NF,不允许部分依赖性(即{S→D,I→B})。 But {IS→Q, B→O} both are allowed in 2NF. 但{2→Q,B→O}都允许2NF。 Finally, relation R is not in 2NF. 最后,关系R不在2NF中。

To achieve 2NF, we decompose the relation R such that decomposition should satisfy lossless join and dependency preserving relations. 为了实现2NF,我们分解关系R,使得分解应该满足无损连接和依赖保持关系。

I decompose it in relations R1(ISQ) with F1={IS→Q}, R2(SD) with F2={S→D}, and R3(IBO) with F3={I→B, B→O}. 我在关系R1(ISQ)中将其分解为F1 = {IS→Q},R2(SD),F2 = {S→D},R3(IBO),其中F3 = {I→B,B→O}。

Now, candidate key(s) and normal form of relations R1, R2, and R3, are {IS} with BCNF, {S} with BCNF, and {I} with 2 NF respectively. 现在,候选密钥和关系R1,R2和R3的正常形式是具有BCNF的{IS},具有BCNF的{S}和具有2NF的{I}。

Since, decomposition R3 is not in 3NF, since FD {B→O}, neither B is Candidate of R3 nor O is prime attribute of R3. 由于分解R3不在3NF中,因为FD {B→O},B既不是R3的候选者也不是O是R3的主要属性。 So, we need to decompose again to achieve 3NF in relation R3 such that decomposition should satisfy lossless join and dependency preserving relations. 因此,我们需要再次分解以在R3中实现3NF,使得分解应该满足无损连接和依赖保持关系。

I decompose R3 in R31(IB) with F31={I→B}, and R32(BO) with F32={B→O}. 我在R31(IB)中分解R3,其中F31 = {I→B},R32(BO),其中F32 = {B→O}。 Now candidate key(s) and normal form of relation R31 and R32 are, {I} with BCNF and {B} with BCNF respectively. 现在,关系R31和R32的候选关键字和正规形式分别为具有BCNF的{I}和具有BCNF的{B}。

Therefore, final BCNF as well as 3NF decomposition is R1(ISQ), R2(SD), R31(IB) and R32(BO). 因此,最终的BCNF以及3NF分解是R1(ISQ),R2(SD),R31(IB)和R32(BO)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM