在将关系R分解成1NF之后存在的表的最小值是多少? [英] Minimum no of tables that exists after decomposing relation R into 1NF?

查看:142
本文介绍了在将关系R分解成1NF之后存在的表的最小值是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑具有以下类型属性的关系R(A,B,C,D,E,F,G): -



1 = {A}



简单(或)原始(或)单值属性组= {B,C}



多值属性组= {D,E}



组合属性集合= {F,G}


$ b b

将关系R分解为1NF后存在的表的最小值是多少?



(A)3(B)2(C)4 )5






我的尝试:



对于具有给定关键字(A)的每个多值属性,total = 2



类似地,我们对于每个复合属性需要不同的表,
$ b

总共有4个这样的属性。我给每个(4)表中的给定密钥(A)的4个表。我允许将原子属性(B,C)插入给定的4个表中的任何一个。因此,我得出结论,4个表足以代表第一个正常形式的关系。


你能用正式的方式解释吗?对于你认为是复合(具有异质部分,如元组)的每个属性,p>


解决方案



对于可能缺少的每个复合属性组件:添加一个关系,其中包含一些候选键的属性和该组件的属性。对于原始关系的每一行,该组件在新关系中有一行,其新属性值是组件的值,并且其候选键属性值是原始行。然后删除组件。



对于每个剩余组件:将一个属性添加到原始关系中,其中每行中的值是组件的值。然后删除composite属性。



对于您认为是多值的属性(具有均匀的部分,如关系):



对于可以具有零个元素的类型的属性:添加具有一些候选键和该属性的属性的关系。对于原始关系的每一行,在新关系中具有一组行,其新属性值是多值属性的元素,并且其候选键属性值是原始行。然后删除多值属性。



对于总是具有元素的类型的属性:将原始关系的每一行替换为一组行的多值属性值是多值属性的元素,其其他属性值是原始行。



所以这里的最终关系是{A,B,C,F1,...,G1,...},{A,D }和{A,E},总计1(对于原始和复合)+ 2(用于多值)。



(如果关系的所有候选键包含多值属性,那么你必须为至少一个多值属性引入一个代理属性。)



当然,实际上你应该规范化新的表, 。但这是为了改善设计。这里我们想要一个尽可能少的添加表的设计。



(没有分解关系到1NF这样的东西。摆脱关系值属性,后来的规范化理论认为每个关系都是1NF。请参见 this re 1NF& atomicity 。
我们可以通过一个或多个关系来替换一个关系,这些属性是我们认为具有同质部分(多值)或异质部分(复合)的属性,我们可以将非关系设计转换为但是非关系型设计不会有候选/主键,因为它只为关系定义。)


Consider the relation R(A, B, C, D, E, F, G) with the following types of attributes:-

Total No of Keys = 1 = {A}

Set of Simple (or) Atomic (or) Single Valued Attributes = {B, C}

Set of Multivalued Attributes = {D, E}

Set of Composite Attributes = { F, G}

What would be the minimum no of tables that exists after decomposing relation R into 1NF?

(A) 3 (B) 2 (C) 4 (D) 5


My attempt:

We needed different table for each multivalued attributes with given key(A), total = 2

Similarly, we needed different table for each composite attributes, total = 2.

There are total 4 such attribute. I give 4 tables with given key(A) in each(4) tables. I'm allowed to insert atomic attributes(B,C) to any one of given 4 tables. So, I concluded that 4 tables are sufficient to represents relation in first normal form.

Can you explain in formal way, please?

解决方案

For every attribute you deem "composite" (having heterogeneous parts, like a tuple):

For every composite attribute component that can be missing: Add a relation with attributes of some candidate key and an attribute for that component. For every row of the original relation that has that component have a row in the new relation whose new attribute value is the value of the component and whose candidate key attribute values are the original row's. Then drop the component. This adds one relation per component that can be missing.

For every remaining component: Add an attribute to the original relation whose value in each row is the value of the component. Then drop the composite attribute. This adds no relations.

For an attribute you deem "multivalued" (having homogeneous parts, like a relation):

For an attribute of a type that can have zero elements: Add a relation with attributes of some candidate key and that attribute. For every row of the original relation have a set of rows in the new relation whose new attribute values are the elements of the multivalued attribute and whose candidate key attribute values are the original row's. Then drop the multivalued attribute. This adds one relation per multivalued attribute.

For an attribute of a type that always has elements: Replace every row of the original relation by a set of rows whose multivalued attribute values are the elements of the multivalued attribute and whose other attribute values are the original row's. This adds no relations.

So the final relations here are {A,B,C,F1,...,G1,...}, {A,D} and {A,E}, a total 1 (for original & composites) + 2 (for multivalued).

(If all the candidate keys of a relation contain multivalued attributes then you have to introduce a surrogate attribute for at least one multivalued attribute.)

Of course, in practice you should normalize the new tables, which may generate new tables. But that is to improve the design. Here we want a design with as few added tables as possible.

(There's no such thing as "decomposing" a relation into 1NF. The original sense of "normalize" meant getting rid of relation-valued attributes. Later normalization theory considers every relation to be in 1NF. See this re 1NF & atomicity. We can replace a relation with attributes that we consider to have homogeneous parts (multivalued) or heterogenous parts (composite) by one or more relations that have attributes for parts instead. And we can convert a non-relational design to a relational one. But that non-relational design won't have a candidate/primary key, because that's defined only for relations.)

这篇关于在将关系R分解成1NF之后存在的表的最小值是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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