Deciding whether a relation is 3NF or 2NF

坚强是说给别人听的谎言 提交于 2019-12-31 03:58:07

问题


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

  • S->SNLRWH (S is the PK)
  • 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.
  • 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.

回答1:


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.

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.




回答2:


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.

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.



来源:https://stackoverflow.com/questions/16614144/deciding-whether-a-relation-is-3nf-or-2nf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!