简体   繁体   English

BCNF,3NF和候选密钥

[英]BCNF, 3NF, and candidate keys

I am having issues understanding how to determine if relations are in BCNF, 3NF, and in general identifying the candidate keys of a relation. 我在理解如何确定BCNF,3NF中是否存在关系以及一般确定关系的候选键方面遇到问题。

Consider relation R = (A, B, C, D) with the functional dependencies: 考虑关系R = (A, B, C, D)与功能的依赖关系:

AB -> C
C -> D
D -> A

The questions included: 问题包括:

a. 一种。 list the candidate keys of R 列出R的候选键
b. b。 determine if R is in BCNF or 3NF. 确定R是在BCNF还是3NF中。

The solution resolves 解决方案

a. 一种。 3 candidate keys for R are AB, BC, and BD. R的3个候选键是AB,BC和BD。
b. b。 R is in 3NF, but not in BCNF. R在3NF中,但在BCNF中不存在。

I've read through What is the difference between 3NF and BCNF? 我已通读3NF和BCNF有什么区别? and can understand the difference between 3NF and BCNF when referring to non-arbituary words within a database schema. 并在引用数据库模式中的非任意词时可以理解3NF和BCNF之间的区别。 I am ultimately lost when trying to determine the relationships with a reduced relation, as given in the problem. 如问题中所给出的那样,当我尝试确定具有简化关系的关系时,我最终迷失了。

Could someone explain how the candidate keys were determined above, and why R is in 3NF but not BCNF? 有人可以解释上面如何确定候选密钥,为什么R在3NF中而不在BCNF中?

You are asking several questions at the same time. 您同时问几个问题。

  1. How to compute the keys of a relation. 如何计算关系的键。 In general, the simplest way is to compute the closure of every single combination of attributes and determine which ones are superkeys. 通常,最简单的方法是计算属性的每个单一组合的闭包,并确定哪些是超键。 From this set of superkeys, find those that are minimal: these are the candidate keys. 从这组超键中找到最小的那些:这些是候选键。

  2. How to determine if a relation is BCNF. 如何确定一个关系是否为BCNF。

FOr this you don't needs keys. 因此,您不需要按键。 All you need to do is test that every non-trivial functional dependency, the left hand side is a superkey of the relation. 您需要做的就是测试每个非平凡的函数依赖关系,左侧是关系的超键。

How do you determine this for a FD? 您如何确定FD? Simply compute the closure of the left hand side of the FD. 只需计算FD左侧的闭合度即可。 If the result is all the attributes of the relation, then it is a superkey. 如果结果是关系的所有属性,则它是一个超键。

  1. How to determine if the relation is 3NF? 如何确定该关系是否为3NF?

FDs must be in Canonical form: one attribute in the right hand side. FD必须采用规范形式:右侧是一个属性。

For every non-trivial FD, either the left hand is a superkey (as in BCNF) or the right hand side is part of a key (any key). 对于每个非平凡FD,要么左手是一个超级键(如BCNF),要么右手是一个键的一部分(任何键)。

This is a very good video that explains the differences: 这是一个非常不错的视频,解释的差异:

BCNF vs 3NF BCNF和3NF

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

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