Database-relational algebra and relational operations

Source: Internet
Author: User

Overview
Traditional set operations (and, poor, intersection, Cartesian product)
Specialized relational operations

and (Union)
R和S具有相同的目n(即两个关系都有n个属性)相应的属性取自同一个域R∪S 仍为n目关系,由属于R或属于S的元组组成             R∪S = { t|t ? R∨t ?S }
Poor (difference)
R和S具有相同的目n相应的属性取自同一个域R - S 仍为n目关系,由属于R而不属于S的所有元组组成                R -S = { t|t?R∧t?S }
Sex (intersection)
R和S具有相同的目n相应的属性取自同一个域R∩S仍为n目关系,由既属于R又属于S的元组组成                    R∩S = { t|t ? R∧t ?S }              R∩S = R –(R-S)
Cartesian product (Cartesian product)
m目关系,k2个元组R×S 列:(n+m)列元组的集合元组的前n列是关系R的一个元组后m列是关系S的一个元组行:k1×k2个元组R×S = {tr ts |tr ?R ∧ ts?S }
Specialized relational operations

First introduce a few tokens

(1) R,t?R,t[Ai]         设关系模式为R(A1,A2,…,An)         它的一个关系设为R          t?R表示t是R的一个元组          t[Ai]
 (2 )   a , T[a ], A  If a  ={ai1,ai2,...,aik}, where Ai1,ai2,...,aik is part of A1,a2,...,an, then   a  is called an attribute column or property group. T[a ]= (T[ai1],t[ai2],...,t[aik]) represents the tuple T in the attribute column A    The collection of the components. a  indicates that the remaining attribute groups after {A1,a2,...,an} are removed from {Ai1,ai2,...,aik}. 
(3tr ts    R为n目关系,S为m目关系。    trtr ts称为元组的连接。    trm列的元组,前n个分量为R中的一个n元组,后m个分量为S中的一个m
(4)象集Zx  给定一个关系R(X,Z),X和Z为属性组。  Set)为:               Zx={t[Z]|t ?R,t[X]=x}    
Connection
1)连接也称为θ连接2)连接运算的含义从两个关系的笛卡尔积中选取属性间满足一定条件的元组     R         S = {          | tr ? R∧ts ?S∧tr[A]θts[B] }A和B:分别为R和S上度数相等且可比的属性组θ:比较运算符     连接运算从R和S的广义笛卡尔积R×S中选取(R关系)在A
3)两类常用连接运算等值连接(equijoin) 什么是等值连接θ为“=”的连接运算称为等值连接 等值连接的含义从关系R与S的广义笛卡尔积中选取A、B属性值相等的那些元组,即等值连接为:        R    S = {          tr ?R∧ts ?S∧tr[A] = ts[B] }  
 Natural connection (Natural join )         A natural connection is a special equivalent connection. The components that are compared in two relationships must be of the same attribute group (same name as the same domain: must have the same property name, and from the same domain set) in the result the repeating attribute column is removed from the natural connection meaning R and s have the same attribute Group B r S = { | tr ? R∧ts?        S∧tr  [B] = ts[b]} The general connection operation is from the angle of the row. Natural joins also require the elimination of repeating columns, so it is the same way of doing operations from both the row and column angles. 
外连接在做自然连接时,如果把舍弃的元组也保存在结果关系中,而在其他属性上填空值(NullJOIN)。左外连接在做自然连接时,如果只把左边关系R中要舍弃的元组保留就叫做左外连接(LEFTJOIN或LEFTJOIN)右外连接在做自然连接时,如果只把右边关系S中要舍弃的元组保留就叫做右外连接(RIGHTJOIN或RIGHTJOIN
Except (division)
 Given the relationship R (x, y) and S (y,z), where x, Y, Z are attribute groups. Y in R and Y in S can have different property names, but must originate from the same set of domains. R and S's divide operation gets a new relationship p (X), p is the projection of tuples on the x attribute column that meet the following conditions in R: Tuple on X component value x  's image set YX contains S set projected on Y, as: R÷s = {tr  [X] | tr ? R∧πy (S)? YX} yx:x  image set in R, x  = tr  [X]  
在关系R中,A可以取四个值{a1,a2,a3,a4}    {(b1,c2),(b2,c3),(b2,c1)}    {(b3,c7),(b2,c3)}    {(b4,c6)}    {(b6,c6)}S在(B,C)上的投影为           {(b1,c2),(b2,c1),(b2,c3) }只有a1的象集包含了S在(B,C)属性组上的投影     所以     R÷S ={a1}

Database-relational algebra and relational operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.