简体   繁体   English

该表是4NF吗?

[英]Is this table 4NF?

I'm trying to design a database. 我正在尝试设计一个数据库。 I have a table as follows: 我有一张桌子,如下所示:

Tag     Post     File
A        a         1
A        a         2
A        a         3
A        b         4
B        a         1
B        b         1
B        c         1
B        d         1

Each post may have more than one tag and each file may have more than one tag. 每个帖子可以具有多个标签,并且每个文件可以具有多个标签。 Aside from the tags the posts and files are unrelated. 除了标签外,帖子和文件都不相关。 Obviously just from looking at the table there are going to be redundancy issues for example the post-tag pair Aa is repeated 3 times unnecessarily, same with the post-file pair B-1. 显然,仅从表来看,就会出现冗余问题,例如,后标记对Aa不必要重复3次,与后文件对B-1相同。 However I've looked at the definitions for 1NF up to 4NF and it seems to be in all of them. 但是,我查看了从1NF到4NF的定义,并且似乎所有定义中都有。

What did I miss? 我错过了什么?

I thought that if a table had redundancies then it's not normalized. 我以为,如果一个表有冗余,那么它就不会被标准化。 But it does seem to be normalized up to 4NF. 但它似乎已被规范化至4NF。 So I must have gone wrong somewhere. 所以我一定在某个地方出错了。

Based on your description you should break down that table into 2 tables to model the One-To-Many relationship between "Post and Tag", and "File and Tag" 根据您的描述,您应该将该表细分为2个表,以建模“ Post and Tag”和“ File and Tag”之间的一对多关系

POST   TAG
a       A
b       A
a       B
b       B
c       B
d       B


FILE   TAG
1       a
2       a
3       a
4       b
1       b
1       c
1       d

Take a look at the first example here: 在这里看第一个例子:

http://en.wikipedia.org/wiki/Fourth_normal_form http://en.wikipedia.org/wiki/Fourth_normal_form

It is typically the same case you are describing in your question. 您在问题中描述的情况通常与情况相同。

Here's a useful question too: 这也是一个有用的问题:

Database Normalization 数据库规范化

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

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