简体   繁体   English

无需复合键即可归一化为1NF

[英]Normalizing to 1NF without composite keys

Its often stated that to reach 1nf, a new entity has to be created and that entity has to have a composite key . 它经常说要达到1nf,必须创建一个新实体,并且该实体必须具有复合密钥

LeadID | leadDate | Name | DOB | streetAddress | city | state | residenceType

If I was to normalize streetAddress, city, state, residenceType into a new entity, I would have to create a new primary key right then and there. 如果要将streetAddress, city, state, residenceType归一streetAddress, city, state, residenceType新实体,则必须在那时和那里创建一个新的主键。 I cannot use LeadID because that would mean that addresses cannot be created without a lead, which is not true. 我不能使用LeadID因为那将意味着没有线索就无法创建地址,这是不正确的。 And I cannot use streetAddress because the streets are not good candidates (5123 glowsville way st. n ave. is not a good key at all). 我不能使用streetAddress因为街道不是很好的候选者(5123 glowsville way st。n ave。根本不是个好钥匙)。

So I am forced to simply create a key for this new entity. 因此,我被迫为这个新实体创建一个密钥。 Is this alright? 这样好吗

First normal form means: 第一个范式表示:

A relation is in first normal form if the domain of each attribute contains only atomic values, and the value of each attribute contains only a single value from that domain. 如果每个属性的域仅包含原子值,并且每个属性的值仅包含该域中的单个值,则关系为第一范式。

So unless you're storing multiple streets in the streetAddress column, you are already complying with first normal form. 因此,除非您在streetAddress列中存储多条街道,否则您已经符合第一个标准格式。

1NF has nothing to do with the presence of composite keys. 1NF与复合键的存在无关。 To satisfy 1NF a table must be an accurate representation of a relation and therefore must have at least one candidate key , which may or may not include composite keys. 要满足1NF,一张表必须是关系的准确表示,因此表必须至少有一个候选键 ,该可能包含也可能不包含复合键。

Possibly you have in mind the Universal Relation Assumption , a concept in database design theory that is sometimes used to teach normalization by decomposition. 可能您会想到通用关系假设 ,它是数据库设计理论中的一个概念,有时用于通过分解来教授归一化。 The URA assumes that a relation exists from which all the desired relations can be obtained by nonloss decomposition. URA假定存在一个关系,可以通过非损耗分解从中获得所有期望的关系。 The universal relation typically has a composite key. 通用关系通常具有复合键。 Note that the URA is itself controversial and definitely questionable but it is one way to think about problems in design theory. 请注意,URA本身是有争议的,并且绝对是有问题的,但这是思考设计理论中问题的一种方法。

Normalization theory strictly never requires the introduction of new attributes. 规范化理论严格来说永远不需要引入新的属性。 In principle the attributes and dependencies are assumed to be a given. 原则上,假定属性和依赖项是给定的。

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

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