决定一个关系是3NF还是2NF

时间:2022-10-04 10:49:43

From the Database Management Systems book: given the relation SNLRWH (each letter denotes an attribute) and the following functional dependencies:

从数据库管理系统手册:给定关系SNLRWH(每个字母表示一个属性)和以下功能依赖项:

  • S->SNLRWH (S is the PK)
  • S->SNLRWH (S为PK)
  • R->W
  • R - > W

My attempt:

我的尝试:

  • 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.
  • 首先,它不是3NF:对于第二个FD, R不包含W, R也不包含键,W也不是键的一部分。
  • 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.
  • 第二,它是/不是2 nf。如果我们检查第二个FD, W依赖于R,而R又不是键的一部分。卡住了。

2 个解决方案

#1


3  

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。问问自己,你的决定因素中是否有一个是候选键的子集。

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.

通常只有当关系具有复合键时才会违反2NF——一个具有多个属性的键。它在技术上是可行的关系只有简单的键(单个属性键)违反2 nf如果空集(∅)恰好是一个行列式。这类案件相当罕见,而且很少被认为值得考虑,因为它们明显是“错误的”。为了完整起见,这里有一个特殊情况的有趣示例。在下面的关系中,周长和直径都是候选键。依赖违反2 nf∅- >π,周长和直径的比值。

决定一个关系是3NF还是2NF

#2


0  

2NF has to do with partial key dependencies. In order for a relation to fail the test for 2NF, the relation has to have at least one candidate key that has at least two columns.

2NF与部分键依赖有关。为了让一个关系在2NF的测试中失败,这个关系必须至少有一个候选键,它至少有两列。

Since your relation has only one candidate key, and that candidate key has only one column, you can't possibly have a partial key dependency. It passes the test for 2NF.

由于您的关系只有一个候选键,而该候选键只有一个列,所以不可能有一个部分键依赖。它通过了2NF的测试。

#1


3  

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。问问自己,你的决定因素中是否有一个是候选键的子集。

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.

通常只有当关系具有复合键时才会违反2NF——一个具有多个属性的键。它在技术上是可行的关系只有简单的键(单个属性键)违反2 nf如果空集(∅)恰好是一个行列式。这类案件相当罕见,而且很少被认为值得考虑,因为它们明显是“错误的”。为了完整起见,这里有一个特殊情况的有趣示例。在下面的关系中,周长和直径都是候选键。依赖违反2 nf∅- >π,周长和直径的比值。

决定一个关系是3NF还是2NF

#2


0  

2NF has to do with partial key dependencies. In order for a relation to fail the test for 2NF, the relation has to have at least one candidate key that has at least two columns.

2NF与部分键依赖有关。为了让一个关系在2NF的测试中失败,这个关系必须至少有一个候选键,它至少有两列。

Since your relation has only one candidate key, and that candidate key has only one column, you can't possibly have a partial key dependency. It passes the test for 2NF.

由于您的关系只有一个候选键,而该候选键只有一个列,所以不可能有一个部分键依赖。它通过了2NF的测试。