可以在没有主键的3NF中使用表吗? [英] Can a table be in 3NF with no primary keys?

查看:150
本文介绍了可以在没有主键的3NF中使用表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


1。
如果满足以下条件的一个,则表将自动以3NF表示:

(i)如果一个关系包含两个属性。

(ii)如果2NF表仅包含一个非关键属性。



2。
如果X→A是一个依赖项,则该表位于3NF中,如果存在以下条件之一:

(i)如果X是超键

(ii)如果A是超键的一部分


我从此网站获得了上述声明。 / p>

我认为在两个声明中,第二个子点都是错误的。



第一个是在如果我们拥有所有非键属性,并且表位于2NF中,则2NF将位于3NF中。



考虑具有依赖项A-的示例R(A,B,C) > B。



此处我们没有候选键,因此所有属性均为非素属性,并且该关系不在3NF中,而是在2NF中。



第二个说,对于形式为X-> A的依赖项,如果A是超键的一部分,则它位于3NF中。



考虑示例R(A,B,C)的依赖关系A-> B,B-> C。这里的CK是{A}。现在超级键之一可以是AC,并且FD B-> C的RHS包含AC的一部分,但是上述关系R不在3NF中。



它应该是A应该是候选键的一部分,而不是超级键



我正确吗?



如果存在<是否存在强功能依赖性?

解决方案

CK(候选键)是不包含更小的超键的超键。超级键是一组唯一的属性。关系是一组元组。因此,每个关系都有一个超键,即所有属性的集合。因此,它至少具有一个CK。



当定义的一组确定属性的每个值始终显示相同的值时,FD(功能依赖项)按定义成立组。每个关系值或变量都满足琐碎的FD,其中确定的集合是确定的集合的子集。每组属性确定{}。因此,每个关系至少满足一个FD。但是,正确的定义形式通常专门讨论非平凡的 FD。不要使用网络,不要使用教科书,尽管并非全部都写得很好,但其中有几十种是免费在线提供的。许多教科书还忘记了行列式和/或确定集为{}的FD。



您的第一点不是3NF的正确定义。由于其用 if ...代替 if and only if,因此它可能不是要作为定义。但是,这仍然是错误的。 (i)是错误的,因为如果其中一个是CK,而另一个在每个元组中具有相同的值(即由{}确定),则具有两个属性的关系不在3NF中。



类似地,第二点不是正确的定义,即使您仅将其视为3NF的结果(如果...),它也是错误的。如果它使用 if并且仅当并讨论拥有FD的 并说它是不平凡的 FD,那将是一个定义。



由于这些既不是正确的定义也不是正确的含义,因此有无数种方法可以反驳它们。读一本书(或我的帖子)并获得正确的定义。






一些评论是您的推理:


第一个说,如果我们具有所有非键属性,并且表位于2NF中,则2NF中的表将位于3NF中。


我不知道你为什么这么认为。


没有候选键


总是有一个或多个CK。您需要阅读CK的定义。也有非蛮力算法可以找到它们。


第二个说法是,对于形式X-> A的依赖性如果A是超级键的一部分,则它在3NF中。


我不知道您为什么会这样。


A应该是候选关键字的一部分,而不是超级关键字。


正确的定义(如第二点)通常会说 ...或(ii)AX是CK的一部分。但是我听不懂您的推理。



合理的推理涉及从假设开始,并写出我们认为是正确的新语句,因为我们应用了定义,即先前证明的语句(定理)或合理的推理规则,例如,根据 A表示B和 A,我们可以得出 B。您似乎需要阅读有关如何操作的信息。


1. A table is automatically in 3NF if one of the following holds:
(i) If a relation consists of two attributes.
(ii) If 2NF table consists of only one non key attribute.

2. If X → A is a dependency, then the table is in 3NF, if one of the following conditions exists:
(i) If X is a superkey
(ii) If A is a part of superkey

I got the above claims from this site.

I think that in both the claims, 2nd subpoint is wrong.

The first one says that a table in 2NF will be in 3NF if we have all non-key attributes and the table is in 2NF.

Consider the example R(A,B,C) with dependency A->B.

Here we have no candidate key, so all attributes are non-prime attributes and the relation is not in 3NF but in 2NF.

The second one says that for a dependency of the form X->A if A is part of a super key then it's in 3NF.

Consider the example R(A,B,C) with dependencies A->B, B->C . Here a CK is {A}. Now one of the super keys can be AC and the RHS of FD B->C contains part of AC but still the above relation R is not in 3NF.

I think it should be A should be part of a candidate key and not super key.

Am I correct?

Also can a particular relation be in 1NF, 3NF or 2NF if there are no functional dependencies present?

解决方案

A CK (candidate key) is a superkey that contains no smaller superkey. A superkey is a unique set of attributes. A relation is a set of tuples. So every relation has a superkey, the set of all attributes. So it has at least one CK.

A FD (functional dependency) holds by definition when each value of a determining set of attributes appears always with the same value for its determined set. Every relation value or variable satisfies "trivial" FDs, the ones where the determined set is a subset of the determining set. Every set of attributes determines {}. So every relation satisfies at least one FD. However, the correct forms of definitions typically specifically talk about non-trivial FDs. Don't use the web, use textbooks, of which dozens are free online, although not all are well-written. Many textbooks also forget about FDs where the determinant and/or determined set is {}.

Your first point is not a correct definition of 3NF. Since its phrased "if..." instead of "if and only if", maybe it's not trying to be a definition. However, it is still wrong. (i) is wrong because a relation with two attributes is not in 3NF if one is a CK and the other has the same value in every tuple, ie it is determined by {}.

Similarly the second point is not a proper definition and also even if you treat it as only a consequence of 3NF (if...) it's false. It would be a definition if it used if and only if and talked about an FD that holds and it said it was a non-trivial FD and some other things were fixed.

Since those are neither correct definitions nor correct implications, there's a unlimited number of ways to disprove them. Read a book (or my posts) and get correct definitions.


Some comments re your reasoning:

First one says that, a table in 2NF will be in 3NF if we have all non key attributes and table is in 2NF.

I have no idea why you think that.

Here we have no candidate key

There's always one or more CKs. You need to read a definition of CK. There are also non-brute-force algorithms for finding them all.

Second one says that, for the dependency of form X->A if A is part of super key then it's in 3NF.

I have no idea why you think that.

A should be part of candidate key and not super key.

A correct defintion like the second point does normally say "... or (ii) A-X is part of a CK". But I can't follow your reasoning.

Sound reasoning involves starting from assumptions and writing new statements that we know are true because we applied a definition, a previously proved statement (theorem) or a sound rule of reasoning, eg from 'A implies B' and 'A' we can derive 'B'. You seem to need to read about how to do that.

这篇关于可以在没有主键的3NF中使用表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆