确定关系是3NF还是2NF [英] Deciding whether a relation is 3NF or 2NF
问题描述
摘自《数据库管理系统》一书:给出了关系SNLRWH(每个字母表示一个属性)和以下功能依赖性:
From the Database Management Systems book: given the relation SNLRWH (each letter denotes an attribute) and the following functional dependencies:
- S -> SNLRWH(S是PK)
- R-> W
我的尝试:
- 首先,它不是3NF:对于第二个FD,R都不包含W,R也不包含键,W也不是键的一部分。
- 第二,是/不是 2NF。如果我们检查第二个FD,则W取决于R,而R则不是键的一部分。 STUCK。
- First, it is not 3NF: for the second FD, neither R contains W, nor R contains a key, nor W is part of a key.
- Second, it is/not 2NF. If we examine the second FD, W is dependent on R, which in turn is not part of a key. STUCK.
推荐答案
如果某些适当的子集违反了2NF候选键作为您(非平凡)依赖项之一的行列式显示。询问自己是否行列式是候选键的子集。
2NF is violated if some proper subset of a candidate key appears as a determinant on the left hand side of one of your (non-trivial) dependencies. Ask yourself whether any of your determinants is a subset of a candidate key.
通常,只有当一个关系具有复合键时,才会违反2NF -一个具有多个属性的键。如果空集(∅)恰好是决定因素,则仅使用简单键(单个属性键)的关系在技术上可能违反2NF。这样的情况是相当不寻常的,并且很少被认为值得考虑,因为它们显然是错误的。为了完整起见,这里有一个有趣的例子。在以下关系中,周长和直径都是候选关键字。违反2NF的依存关系是∅-> Pi,即周长与直径的比率。
Usually 2NF is violated only when a relation has a composite key - a key with more than one attribute. It is technically possible for a relation with only simple keys (single attribute keys) to violate 2NF if the empty set (∅) happens to be a determinant. Such cases are fairly unusual and rarely thought worthy of consideration because they are so obviously "wrong". For completeness, here's a fun example of that special case. In the following relation Circumference and Diameter are both candidate keys. The dependency in violation of 2NF is ∅ -> Pi, the ratio of the circumference to the diameter.
这篇关于确定关系是3NF还是2NF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!