简体   繁体   English

Boyce Codd分解后剩余的功能依赖?

[英]Leftover functional dependencies after Boyce Codd decomposition?

This decomposition example was given in class, however the solution is confusing as it seems to leave some FD's unaddressed. 这个分解的例子是在课堂上给出的,但解决方案令人困惑,因为它似乎让一些FD无法解决。 Please confirm 3) below is in BCNF, or cannot be put into BCNF? 请确认3)以下是BCNF,还是不能投入BCNF?

Let R be a relation schema, with schema(R) = {C,T,H,R,S,G}

set of FDs F over R :
C->T
HR->C
HT->R
CS->G
HS->R

Decomposition: 分解:

1) C T H R S G
2) C T      C H R S G
3) C T      H R C       H R S G 
end. (Not further decomposed.)

In 3) HRSG contains attributes R and G without appearing to satisfy ht->r or cs->g. 在3)HRSG包含属性R和G而不满足ht-> r或cs-> g。

ht->r is discounted because we don't have t in HRSG cs->g is discounted because we don't have c in HRSG ht-> r打折,因为我们没有HRSG cs-> g打折,因为我们在HRSG中没有c

Is there a rule that if the LHS of a functional dependency contains attributes not in the relation, the FD doesn't apply? 是否存在这样的规则:如果函数依赖的LHS包含不在关系中的属性,则FD不适用? Thanks 谢谢

The FD still applies to the overall db design. FD仍然适用于整体数据库设计。

Every FD is always the expression of some business rule. 每个FD都是一些商业规则的表达。 All stated business rules always apply, regardless of whether they are to be enforced on a 1-table version of the database schema, or on a decomposed version thereof. 无论是在数据库模式的1表版本上还是在其分解版本上强制执行,所有声明的业务规则始终适用。 However, expressing them as an FD requires that all the attributes involved in the FD appear in the same relvar (because that's how they were invented : as a way of expressing a rule that applies to a relation schema (note that it does not say "database schema" here). The logical consequence is that FD's are simply incapable of expressing rules that "span" more than just one relation schema. The logical consequence of that is that it is no more than normal that "decomposing a relation schema" will/might lead some FD's becoming inexpressible ( not "inapplicable" ) in the new version. 然而,表达他们作为FD要求所有参与FD属性出现在同一relvar(因为这是他们是如何发明:为表达适用于一个关系模式的规则的一种方式(请注意,它说“数据库模式”在这里)。合乎逻辑的结果是,FD的只是不能表达的规则,即‘跨越’不仅仅是一个关系模式。 合乎逻辑的结果是,它并不比正常的更是‘分解关系模式’,将/可能导致一些FD在新版本中变得无法表达( 不是 “不适用” )。

(1) FD's that are still expressible after decomposition / normalization to BCNF, can be "implemented" by declaring the LHS of the FD as a key to the relation schema. (1)在对BCNF进行分解/归一化之后仍然可以表达的FD可以通过将FD的LHS声明为关系模式的关键来“实现”。

(2) FD's that have become inexpressible in a decomposed schema, will have to be reinstated in the overall database design under the form of a database constraint. (2)在分解模式中已经无法表达的FD必须在数据库约束的形式下在整个数据库设计中恢复。 This "database constraint" is very similar to the key constraints corresponding to those FD's from (1), in that these database constraints are also a "key" of a sort, they are just not a key to a relation in the database schema, instead they are a key to a "virtual" relation (aka "view") that is definable in the database schema. 这个“数据库约束”非常类似于对应于来自(1)的那些FD的关键约束,因为这些数据库约束也是排序的“关键”,它们不是数据库模式中关系的关键,相反,它们是在数据库模式中可定义的“虚拟”关系(也称为“视图”)的关键。 This view is a projection (on exactly the attributes mentioned in either side of the FD) of the JOIN(s) (thus, the "recomposition from the decomposed parts") of the involved relation schemas. 该视图是所涉及的关系模式的JOIN(s)(因此,“从分解的部分重构”)的投影(完全是在FD的任一侧中提到的属性)。

That's a lot of words and maybe hard to follow, but the procedure is (for cs->g) : join back together the decomposed relation schemas (over HR, giving us a relation HRCSG back again), project down to the attributes involved in the FD (thus, project down to CSG), and in this relation, CS must be a key. 这是很多单词,也许很难遵循,但程序是(对于cs-> g):将分解的关系模式(通过HR,再次给我们HRCSG关系)重新连接起来,投射到涉及的属性FD(因此,投射到CSG),在这种关系中,CS必须是关键。

Note that I say "key" here in the sense that it cannot be allowed for the same CS value combination to appear with different G values. 请注意,我在这里说“key”,因为不能允许相同的CS值组合出现不同的G值。 Not in the sense that this is a declaration that you could make to any DBMS to enforce such a rule. 从某种意义上说,这是一个声明,您可以向任何DBMS强制执行此类规则。 If DBMS's could effectively do this, database design would be a lot easier :-) Meaning the enforcement of the rule, and seeing to it that no data will ever violate this rule, is now up to you. 如果DBMS可以有效地做到这一点,那么数据库设计会更容易:-)这意味着规则的执行,并确保没有数据会违反这条规则,现在取决于您。

Fortunately, in practice these cases are not too numerous, and most of the time you will notice that the vast majority of the FD's in your original version, end up simply as keys declared on BCNF tables. 幸运的是,在实践中,这些情况并不是太多,而且大多数时候您会注意到原始版本中的绝大多数FD最终只是在BCNF表上声明的键。

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

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