了解关系代数中的自然连接 [英] Understanding natural join in Relational algebra

查看:714
本文介绍了了解关系代数中的自然连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到自然连接只是选择和笛卡尔乘积的组合,但是在各种网站中,自然连接被称为投影和笛卡尔乘积的组合,两者完全不同,因此哪个定义应该更准确地对应呢?

I have seen that natural join is just combination of selection and cartesian product but in various websites its said to be as combination of projection and cartesian product and both are completely different so which definition should corresponds to it more exactly?

推荐答案

关系代数有许多不同的版本,即使它们的关系概念不同。没有产品或自然联接。

There are many different versions of "relational algebra" that differ even in their notion of "relation". There's no one PRODUCT or NATURAL JOIN.

关系代数的某些版本具有作为属性名称列表的关系标题。 PRODUCT为每个输入列表元素输出一个属性。如果存在一个NATURAL JOIN,则其结果将类似于首先进行PRODUCT,然后对相同名称的属性对相等进行限制/选择,然后对每个属性中的一个属性进行投影。没有共享属性名称时,它们会给出相同的结果。 PRODUCT可用于任何两个输入,但是当输入具有重复的属性名称时,NATURAL JOIN可能是未定义的。

Some versions of the relational algebra have relation headings that are lists of attribute names. PRODUCT outputs an attribute for every input list element. If there's a NATURAL JOIN then its result will be like first doing PRODUCT, then RESTRICTing/SELECTing on equality of pairs of same-named attributes, then PROJECTing out one attribute of each pair. They give the same result when there are no shared attribute names. PRODUCT works for any two inputs but NATURAL JOIN might be undefined when an input has duplicate attribute names.

某些关系代数版本的关系标题为属性名集。 (元素是无序的和唯一的。)NATURAL JOIN的结果的标题为输入标题的并集。 (Tuples对两个输入共有一个属性名称的每个副本,而对一个输入唯一的每个属性名称一个副本。)它返回所有元组,其标题可以通过合并来自每个输入表的元组来形成。不管有多少个通用属性名称,包括零。仅当输入不共享属性名称,而其他行为类似于NATURAL JOIN时,才定义PRODUCT。 PRODUCT的作用是确认您期望没有共享的属性名称。当所有列名都相同时,这就是一种相交。

Some versions of the relational algebra have relation headings that are sets of attribute names. (Elements are unordered & unique.) The result of NATURAL JOIN has a heading that is the union of the input headings. (Tuples have one copy each of the attribute names common to both inputs & one copy each of the attribute names unique to one input.) It returns all tuples with that heading that can be made by combining a tuple from each input table. That is regardless of how many common attribute names there are, including zero. PRODUCT is defined only when the inputs share no attribute names but otherwise acts like NATURAL JOIN. PRODUCT's role is to confirm that you expect that there are no shared attribute names. When all the column names are common, that is a kind of INTERSECTION.

所有这些都与PK,UNIQUE,FK和Amp无关。其他限制条件。

All this is regardless of PKs, UNIQUE, FKs & other constraints.

这篇关于了解关系代数中的自然连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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