这个表违反了哪个正常形式? [英] Which normal form does this table violate?

本文介绍了这个表违反了哪个正常形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑这个表:

  + ------- + ------- + ----- + ------- + 
|名称| hobby1 | hobby2 | hobby3 |
+ ------- + ------- + ------- + ------- +
| kris |球游泳|舞蹈|
| james |吃|唱|睡眠|
| amy |游泳|吃|手表|
+ ------- + ------- + ------- + ------- +

爱好的类型没有优先级,因此所有的爱好属于同一个域。也就是说,表中的爱好可以在任何 hobby#列上移动。



此表违反了哪个数据库规范化规则? / p>




编辑



是爱好的列表[...]在任意顺序?



A。是。



Q。表有主键吗?



A。是,假设键是名为 user_id AUTO_INCREMENT 列类型。


$ b $问题是如果 hobby#是重复的组。






Sidenote :这不是家庭作业。这是一个辩论,开始在问题的评论 SQL - 根据多个列将记录从一个表匹配到另一个表。我相信这个问题是1NF违规的一个明显例子。



但是,另一个人认为我已经堕落了1NF的一个谬误。该参数基于重复群体的模糊性的文章关于第一正常形式的事实和谬误



我不是在写这个侮辱他,我或任何人。我写这个,因为我可能错了,有一些我显然缺失,也许这家伙没有解释它对我足够好。

解决方案

你说的爱好属于同一个域,他们可以在列中移动。如果这意味着对于任何特定的名称爱好列表是任意顺序和kriss可以很容易舞蹈,球,游泳如球,游泳,舞蹈,那么我会说你有一个重复的组,表违反了1NF。



另一方面,如果某个人的第一个和第二个之间有一些基本的语义差异,第二爱好,则可以存在用于说爱好不是重复组并且表可以在3NF(假设爱好列是FK到爱好表)的参数。我建议这个论点,如果存在,是弱的。



另一个要考虑的因素是为什么有3个爱好和更多或更少的爱好是潜在的关心。这个因素对于标准化和设计灵活性来说并不重要。这是我将爱好分成行的一个原因,即使它们在语义上彼此不同。


Consider this table:

   +-------+-------+-------+-------+  
   | name  |hobby1 |hobby2 |hobby3 |  
   +-------+-------+-------+-------+   
   | kris  | ball  | swim  | dance |  
   | james | eat   | sing  | sleep |  
   | amy   | swim  | eat   | watch |  
   +-------+-------+-------+-------+

There is no priority on the types of hobbies, thus all the hobbies belong to the same domain. That is, the hobbies in the table can be moved on any hobby# column. It doesn't matter on which column, a particular hobby can be in any column.

Which database normalization rule does this table violate?


Edit

Q. Is "the list of hobbies [...] in an arbitrary order"?

A. Yes.

Q. Does the table have a primary key?

A. Yes, suppose the key is an AUTO_INCREMENT column type named user_id.

The question is if the columns hobby# are repeating groups or not.


Sidenote: This is not a homework. It's kind of a debate, which started in the comments of the question SQL - match records from one table to another table based on several columns. I believe this question is a clear example of the 1NF violation.

However, the other guy believes that I "have fallen fowl of one of the fallacies of 1NF." That argument is based on the section "The ambiguity of Repeating Groups" of the article Facts and Fallacies about First Normal Form.

I am not writing this to humiliate him, me, or whomever. I am writing this, because I might be wrong, and there is something I am clearly missing and maybe this guy is not explaining it good enough to me.

解决方案

You say that the hobbies belong to the same domain and that they can move around in the columns. If by this you mean that for any specific name the list of hobbies is in an arbitrary order and kriss could just as easily have dance, ball, swim as ball, swim, dance, then I would say you have a repeating group and the table violates 1NF.

If, on the other hand, there is some fundamental semantic difference between a particular person's first and second hobbies, then there may be an argument for saying that the hobbies are not repeating groups and the table may be in 3NF (assuming that hobby columns are FK to a hobby table). I would suggest that this argument, if it exists, is weak.

One other factor to consider is why there are precisely 3 hobbies and whether more or fewer hobbies are a potential concern. This factor is important not so much for normalization as for flexibility of design. This is one reason I would split the hobbies into rows, even if they are semantically different from one-another.

这篇关于这个表违反了哪个正常形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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