SlideShare a Scribd company logo
Relational Algebra
1
Fall 2001 Database Systems 1
Relational Algebra
• A relation is a set of tuples. Each relational
algebra operation takes as input a list of
relations and produces a single relation.
• General form:
OperatorArguments (List of Relations)
 
New Relation
• After each operation, the remaining attributes
are carried to the new relation. The attributes
may be renamed, but their domain remains the
same.
Fall 2001 Database Systems 2
Set Theoretic Operations
• Regular set operations on relations
• A set operation requires two participating relations R and
S to be compatible
– R and S should have the same attributes
• R(Name:D1, Email:D2)
• S(Name:D1, Email:D2, Address:D3)
• T(Name:D1, Email:D4)
• V(Name:D1, Email:D2)
Which relations above are union (set operation)
compatible?
– Union compatibility may require type conversion
(casting).
Relational Algebra
2
Fall 2001 Database Systems 3
Set Operations
 ¢¡¤£¦¥ §©¨£ ¥¡  ! #¤$%¥(')0¥$¡1$) 
243©5 673
SR ∪
8 9 @BADC7E F©GIHQP©RDHSR©T¤F
F 5H QPUFVT 5 3 8 6 T 9
W 3 H¤FVTGQFVXYH 56 V3
SR ∩
8 9 @BADC7E F©GIHQP©RDHSR©T¤F
` 6 HDP 5 3 8aR 3Yb 9
c 5d Qd FVT¤F 3 XQF
SR −
8 9 @BADC7E F©GIHQP©RDHSR©T¤F 5 3
8e`¦AQH 36 H 5 3 9
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Fall 2001 Database Systems 4
pYq¢rs0t%u pQvw r¤x€y¤ ‚yx0vƒ
„Y… †(‡Yˆ‰  Smith@aol.com
„Y‘ ’“€”€•—– Johns@geocities.com
˜™ d0e “gf)• Brown@netmail.com
˜h i1e j—k Gray@microsoft.com
l0m)n)o0p0q l‚r s0tu vw‚xy o0x w0tz
{%| })~  € Gray@microsoft,com
{% ‚‚ƒ‚„g…‚~ † ‡ Robert432@aol.com
{0ˆ ‰ƒgŠ‚‹—‡ Johns@somewhere.com
{€Œ ‰—‡ ƒg‹ Jj@yahoo.com
{0 Ž(g—… Duke@jazz.com‘g’¤“0”Q• ‘0–— ˜Q–— ™š‚›œ —–ž—Ÿ  g¡ œ ¢g£gž š€Ÿ—–£g¤
¥%¦ §Y¦ ¨)© ª‚«¬‚­ ®€¯€­ ° ¯g±
¥%² §Y² ³1´µgµ€´± ¶U®%´· ¸ ¹ ¯gº—­ ° ¯€±
¥0» §Y² ¼¬%«¬‚­ © ¯gµ—¬ ½¤¬€¾¦¿¯€· À
¥€Á §» ‚¯gäµ—ª—­ ­ ³ª‚« «ª—­
Ä0Å ÆÇ ÈÉ Ê€Ëg̤͂ʂΗςÐ
É€ÑÒ Ó—Ô Ô Ê ÕÖ
Ó—× ×—Ø
Ö
Ä0Ù ÆYÚ Æ¤Û€ÑË—ÜÝÉ€ÑÛ
Ö Þ
Ê€Ô × Êgß
à‚áâ%ã à%äå â%æ€ç è á‚äå à0é—êgá€å ë1ì¤í—égî ç
ï0ðñ%ò ó0ô—õ€ö ÷%ò ïø òù
ï0ðñ%ø ó0ô—õ€ö ÷gú ï%ù û0ù
ï0ðñ0õ ó0ô—õ%ò ÷%ò ï€ú òó
ï0ðñgú ü%ôgò ÷0ù ï%ù ý%ù
ï0ðñ0ù ü%ôgò ÷%ò ïø øgö
ï0ðñ0û ü%ôgø ÷gú ï€ú ý‚ö
ï0ðñ‚ý ü%ôgø ÷%ø ïò ú
ï0ðñ0ó ü%ô—õ ÷%ø ï%õ ù
Relational Algebra
3
Fall 2001 Database Systems 5
Assignment and Alias
• Given a relation R, head(R)=A1…An is the list of attributes
in R.
• For each attribute, dom(A) gives the domain of A,
name(A) gives the name of the attribute
• Suppose B1…Bn is a list of attributes such that for each i,
dom(Bi) = dom(Ai)
Then assignment (:=) changes the names of some or all of
the attributes in R and results in a new relation S,
S(B1…Bn) := R(A1…An)
and dom(B1) = dom(A1) … dom(Bn) = dom(An).
Fall 2001 Database Systems 6
Set Operations
• Find all people who are registered as buyers or owners
 ¢¡¤£¦¥¨§©   ! ! #
$% ')(10 243 Smith@aol.com
$65 798@3¤ACB Johns@geocities.com
DE% F¦GIHCP Gray@microsoft.com
QRQRQ QRQ@Q QRQRQ
BUYERS-2(oid,name,email) :=
BUYERS(buyid,name,email)
RESULT := BUYERS-2 ∪ OWNERS
Relational Algebra
4
Fall 2001 Database Systems 7
Set Operations
• Find all people who are owners but not buyers
 ¢¡¤£¦¥¨§©   ! !¤ #
$% ')(0 132 Smith@aol.com
$4 5768293@ Johns@geocities.com
$¨A B¦CED3F Gray@microsoft.com
G G G
BUYERS-2(oid,name,email) :=
BUYERS(buyid,name,email)
RESULT:= OWNERS - BUYERS-2
Fall 2001 Database Systems 8
Set Operations
• Find all people who are both owners and buyers
HPI7QSRUTV WYX ` acb7dUe e7dUbfXhg
BUYERS-2(oid,name,email) :=
BUYERS(buyid,name,email)
RESULT := OWNERS ∩ BUYERS-2
Relational Algebra
5
Fall 2001 Database Systems 9
Projection
• Select all tuples from relation R, restrict each tuple to the
input attributes
– written as R[A1…An] or
for attributes A1…An from R
– meaning
nAA ...1
π
for each tuple in R
construct a new tuple containing
only attributes A1…An
place the new tuple in the result
end-for
remove duplicate tuples to preserve
the set property
Fall 2001 Database Systems 10
Projection
• Find the names and email addresses of people who are
both buyers and owners
 ¢¡¤£¦¥¨§©  !#
$%('0) G ra y @ m ic ro s o ft.c o m
RESULT:= OWNERS[name,email] ∩ BUYERS[name,email]
Relational Algebra
6
Fall 2001 Database Systems 11
Projection
• Find all the items on which at least one bid was placed
 ¢¡¤£¦¥¨§© 


!
#
RESULT := BIDS[iid]
Fall 2001 Database Systems 12
Selection
• Select certain tuples from a relation R based on a boolean
condition C
– written as R where C or
– meaning:
RCσ
for each tuple t in R
if t makes C true then
return t in the resulting relation
end-for
Relational Algebra
7
Fall 2001 Database Systems 13
Selection
• The selection condition C is built of
– atomic conditions of the form Ai ∝ Aj or Ai ∝ c where
• Ai, Aj are attributes and c is a constant of the same domain of
values, and
• ∝ is a comparison predicate of the form: =,  ,  , = , = , etc.
• If C1, C2 are selection conditions, then so are
• C1 AND C2
• C1 OR C2
• NOT C1
Fall 2001 Database Systems 14
Selection
• Find the bid identifiers of bids for item number “I1”:
 ¢¡¤£¦¥¨§© 
 !
 $#
 ¤%
I1-BIDS := BIDS WHERE iid = “I1”
RESULT := I1-BIDS[bid]
Relational Algebra
8
Fall 2001 Database Systems 15
Selection
• Find the bid identifiers of bids for item number “I1” that are
strictly more than $15.
I1-BIDS := BIDS WHERE
iid = “I1” AND amount  15
RESULT := I1-BIDS[bid]
 ¢¡¤£¦¥¨§© 
!
#
Fall 2001 Database Systems 16
Selection
• Find the dates in which a bid for item number “I1” or
“I5” was placed
I1orI5-BIDS := BIDS WHERE
iid = “I1” OR iid = “i5”
RESULT := I1orI5-BIDS[date]
$%('#)¤021 3542687
9A@2BDC
9A@2BFE
G(@HE
Relational Algebra
9
Fall 2001 Database Systems 17
Cartesian Product
• Multiply the relations R and S, producing |R|x|S| many
tuples with attributes head(R)+head(S)
• Cartesian product combines two relations into one “big”
relation
• meaning
for each tuple r in R do
for each tuple s in S do
compute a new tuple containing
all attributes in r and s
end-for
end-for
Fall 2001 Database Systems 18
R := Bids WHERE Amount  20 T := Items WHERE oid=“O2”
S := T[iid,name]
P := R X S
  ¡£¢ ¤ ¥§¦©¨ ¢ ¤ ¡¤ !#©$¨
% '( )0213 465 %7 8£7
% '5 9@0A 47 %7 BC7
% '@8 9@02( 465 %5 B3
D EF G HPIQSR
T@U VXW Y2YW `badc£W egf
h@i p£q£r qstuY6q
v w§x€y‚ ƒ w§x „£…†b‡ w§x ˆ ƒ w‰x€y2g‘2ˆ6ƒ w§x ’§“X”•–† —Sx ˆ ƒ —Sx ˜#…©“X‡
™d e@f g2h6i6j kl ™m n‚m k2f oCd pp©d qgr
™d ste
™d e©l u2h©v k2m ™m w@m k2f oCd pp©d qgr
™d ste
™d en u2h©f kl ™l wj k2f oCd pp©d qgr
™d ste
™d e@f g2h6i6j kl ™m n‚m k©i x‚y@zy©{b|–}2pgy
™d e©l u2h©v k2m ™m w@m k©i x‚y@zy©{b|–}2pgy
™d en u2h©f kl ™l wj k©i x‚y@zy©{b|–}2pgy
Relational Algebra
10
Fall 2001 Database Systems 19
Relational Algebra - Join
• For all pairs of tuples r and s from relations R and S where
Head(R)=A1…AnB1…Bk and Head(S)=B1…BkC1…Cm
such that r[B1…Bk] = s[B1…Bk],
include a tuple in R
 ¢¡ S with
attributes A1…AnB1…BkC1…Cm
• The attributes in common between the two relations (B1…Bk) are
called the “join attributes”
• The join is a cartesian product followed by a selection on the join
attributes, and a projection to remove the duplication of the join
attributes [formally: you have to rename the join attributes in one
relation so that you can express the selection/projection
operations]
Also called equijoin since
the main criteria is the
equality of join attributes
Fall 2001 Database Systems 20
Relational Algebra - Join
• Find all people with the same name and email address from the
“buyers” and “owners” relations
– join attributes are “Name” and “Email” from the buyer and
owners relations
– the joined relation will have attributes “Buyid, Name, Email, Oid”
– there are 5 × 4 pairs of tuples to compare on the attributes
“Name” and “Email”
£¥¤§¦©¨
¥  ¨¥
£!$#%' )(1032 ¨ 03( %54  %'
67 8@9BADC G r a y @ m ic ro s o ft,c o m E3F
Relational Algebra
11
Fall 2001 Database Systems 21
Relational Algebra - Join
 ¢¡¤£¦¥¢§¢¨  ¢©  Gray@microsoft,com
 !# $% Smith@aol.com
#')(10323
45 6¤798A@B Johns@geocities.com
4DC)E#F¢GIH
PDQ RASUTWVYX Brown@netmail.com `badcDegf3h
iqp r¤sUtvu Gray@microsoft.com
ixw€ybA‚¢ƒ
„¢…¤†¦‡¢ˆ¢‰ „¢ ‘’“” Gray@microsoft,com
„¢…¤†¦‡¢ˆ¢‰ „¢ ‘’“” Gray@microsoft,com
•¢–¤—¦˜¢™¢d •¢e fghi Gray@microsoft,com
Example below shows four of the twenty pairs of tuples
considered for the join
Fall 2001 Database Systems 22
Relational Algebra - Join
• Find the names of items with bids over $20
• Find the names of the owners of items with bids over $20
and are located in Boston
Temp1 := Bids WHERE Amount  20
Temp2 := Items jlk Temp1
Result := Temp2[Name]
Temp1 := Bids WHERE Amount  20
Temp3 := Items WHERE Location = “Boston”
Temp2 := Temp3 jlk Temp1
Temp4 := Temp2 jlk Owners
Result := Temp4[Owners.Name]
Relational Algebra
12
Fall 2001 Database Systems 23
Relational Algebra - Division
• Let head(R)=A1…AnB1…Bk and head(S)= B1…Bk
• R ÷ S is the “maximal” set of tuples from R[A1…An] such that
R contains all tuples in (R ÷ S) x S.
• Division is often
used for “for-all”
queries, e.g. “Find
tuples in R that are
in a relation with
‘all’ tuples in S.”
• All the attributes in the dividing relation S must exist in the
divided relation R!
for all tuples r in R[A1…An]
if for all tuples s in S, r+s is in R
place r in R ÷ S
end-if
end-for
Fall 2001 Database Systems 24
Relational Algebra - Division
  ¡ ¢ £
¤¦¥ §¨¥ ©¥
¤ §¨¥ ©¥
¤¦¥ § ©¥
¤¦¥ § ©
¤ §¨¥ ©
¤¦¥ § ©
¤¦¥ § ©
¤¦¥ §¨¥ ©
!
$#
$%
 ' (
)10 230
4 5 6
798 @38
7BA @38
Find:
• R ÷ S
• R ÷ V
• R ÷ Y
C DEGFIH¦PQSR TUR VXW
÷ S
Relational Algebra
13
Fall 2001 Database Systems 25
Relational Algebra - Division
  ¡ ¢ £
¤¦¥ §¨¥ ©¥
¤ §¨¥ ©¥
¤¦¥ § ©¥
¤¦¥ § ©
¤ §¨¥ ©
¤¦¥ § ©
¤¦¥ § ©
¤¦¥ §¨¥ ©
!
$#
$%
 ' (
)10 230
4 5 6
798 @38
7BA @38
Find:
• R ÷ S
• R ÷ V
• R ÷ Y
Fall 2001 Database Systems 26
Relational Algebra - Division
• Find identifiers of buyers who placed a bid on “all” the items
• Find the identifiers of items that have a bid from “all” the buyers
Temp := Items[Iid]
Temp1:= Bids[Buyid,Iid]
Result := Temp1 ÷ Temp
A := Buyers[BuyId]
B := Bids[Iid, BuyId]
Result := B ÷ A
Relational Algebra
14
Fall 2001 Database Systems 27
Relational Algebra Operations
– Union R ∪ S
– Intersection R ∩ S
– Difference R - S
– Assignment S(B1…Bn) := R(A1…An)
– Selection R where C
– Projection R[A1…An]
– Cartesian Product R x S
– Join R
 ¢¡ S
– Division R ÷ S
Fall 2001 Database Systems 28
£¥¤§¦¥¨© £¥ ¦  !!#
$¥% (')021 Smith@aol.com
$¥3 465718@9 Johns@geocities.com
$A BC@5EDF8 Brown@netmail.com
$ G H(CPIRQ Gray@microsoft.com
S!TFU(VWX SY2`bac d¥ef g Vfe!ah
ibp qsrut2v Gray@microsoft,com
iw xy7€7!r@‚Pƒ Robert432@aol.com
i„ …6y7†‡Pƒ Johns@somewhere.com
i7ˆ …6tRƒRy!‡ Jj@yahoo.com
i‰ (‘E’@ Duke@jazz.com “R”F•–— “˜™ de˜™ f
gEh(i j2kRl2g2m
˜
kon
p7q req sbtuuvwRx yEz@x@{Pz7|
p7} re} ~6€R€o|u
y‚„ƒ …
zo†PxP{Pz7|
pE‡ re} ˆ!wvwox2t@zR€@w ‰FwoŠ
‹zR‚@Œ
2Ž  ‘7’o“s”@•2–P– —!•˜˜•@–
E™ FŽ š› 2’Rœ2
ž’oŸR 7¡
›R¢£u•2–P–@’
¤!¥ •@¦P¦o˜¥
o§ e¨ ›R¢” ¥ © ’@–@¦P’7ª
«!¬­(® «b¯° ­(±E²@³ ¬!¯° «´2µ¬E° ¶s· ¸7´E¹2²
º»¼b½ ¾!¿7À7Á ½ ºÃ ½uÄ
º»¼bà ¾!¿7À7Á ÂRÅ ºÄ ÆÄ
º»¼À ¾!¿7À½ ½ º7Å ½„¾
º»¼Å Ç!¿½ ÂEÆ ºÄ ÈbÄ
º»¼Ä Ç!¿½ ½ ºÃ ÃEÁ
º»¼Æ Ç!¿Ã ÂRÅ º7Å È!Á
º»¼!È Ç!¿Ã Âà º½ Å
º»¼¾ Ç!¿7À Âà ºÀ Ä
Auction Database
Relational Algebra
15
Fall 2001 Database Systems 29
Problem 1
Find the name and email of owners of items located in
“Boston”
A := Items WHERE Location = “Boston”
B := A
 ¢¡ Owners
Result := B[Owners.Name, Owners.Email]
Fall 2001 Database Systems 30
Problem 2
Find the identifiers and amount of bids placed by
buyer “Roberts”
A := Buyers WHERE Name = “Roberts”
B := A
 ¢¡ Bids
Result := B[Bid, Amount]
Relational Algebra
16
Fall 2001 Database Systems 31
Problem 3
Find the names of buyers who placed a bid on an item
owned by “Brown”
A := Owners WHERE Name = “Brown”
B := (A
 ¢¡ Items) [Iid]
C := B
 ¢¡ Bids
Result := (C
 ¢¡ Buyers) [Buyers.Name]
Fall 2001 Database Systems 32
Problem 4
Find the identifier of items with more than one bid
A := Bids[Bid, Iid]
B := A x Bids[Bid,Iid]
C := B WHERE (A.Bid  Bids.Bid)
AND (A.Iid = Bids.Iid)
Result := C[Iid]
Relational Algebra
17
Fall 2001 Database Systems 33
Problem 5
Find the names of items all buyers placed a bid on
A := (Bids[Iid, BuyId]) ÷ (Buyers[Buyid])
B := A
 ¢¡ Items
Result := B[Name]

More Related Content

Viewers also liked

Tecnologo en gestión logística
Tecnologo en gestión logísticaTecnologo en gestión logística
Tecnologo en gestión logística
Elvia Padilla
 
Verbinding in de keten FFF2017
Verbinding in de keten FFF2017Verbinding in de keten FFF2017
Verbinding in de keten FFF2017
TOPdesk
 
Extending the Yahoo Streaming Benchmark + MapR Benchmarks
Extending the Yahoo Streaming Benchmark + MapR BenchmarksExtending the Yahoo Streaming Benchmark + MapR Benchmarks
Extending the Yahoo Streaming Benchmark + MapR Benchmarks
Jamie Grier
 
Digestion biochemistry
Digestion biochemistryDigestion biochemistry
Digestion biochemistry
santusan
 
Constitucion española
Constitucion española Constitucion española
Constitucion española
Ernesto Suarez Gonzalez
 
Mozilla at Darbar college
Mozilla at Darbar collegeMozilla at Darbar college
Mozilla at Darbar college
Shreyas Kutty
 
Manual en español syma x8 c venture
Manual en español  syma x8 c ventureManual en español  syma x8 c venture
Manual en español syma x8 c venture
Manuel Cristóbal Muñoz Jiménez
 

Viewers also liked (7)

Tecnologo en gestión logística
Tecnologo en gestión logísticaTecnologo en gestión logística
Tecnologo en gestión logística
 
Verbinding in de keten FFF2017
Verbinding in de keten FFF2017Verbinding in de keten FFF2017
Verbinding in de keten FFF2017
 
Extending the Yahoo Streaming Benchmark + MapR Benchmarks
Extending the Yahoo Streaming Benchmark + MapR BenchmarksExtending the Yahoo Streaming Benchmark + MapR Benchmarks
Extending the Yahoo Streaming Benchmark + MapR Benchmarks
 
Digestion biochemistry
Digestion biochemistryDigestion biochemistry
Digestion biochemistry
 
Constitucion española
Constitucion española Constitucion española
Constitucion española
 
Mozilla at Darbar college
Mozilla at Darbar collegeMozilla at Darbar college
Mozilla at Darbar college
 
Manual en español syma x8 c venture
Manual en español  syma x8 c ventureManual en español  syma x8 c venture
Manual en español syma x8 c venture
 

Similar to [Www.pkbulk.blogspot.com]dbms04

Lecture5
Lecture5Lecture5
Lecture5
11000907
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational model
ATS SBGI MIRAJ
 
Data Base Management system relation algebra ER diageam Sql Query -nested qu...
Data Base Management system relation algebra ER diageam Sql Query -nested  qu...Data Base Management system relation algebra ER diageam Sql Query -nested  qu...
Data Base Management system relation algebra ER diageam Sql Query -nested qu...
kudiyarc
 
DDL,DML,1stNF
DDL,DML,1stNFDDL,DML,1stNF
DDL,DML,1stNF
Bala Ganesh
 
sfdfds
sfdfdssfdfds
sfdfds
Bala Ganesh
 
1695304562_RELATIONAL_ALGEBRA.pdf
1695304562_RELATIONAL_ALGEBRA.pdf1695304562_RELATIONAL_ALGEBRA.pdf
1695304562_RELATIONAL_ALGEBRA.pdf
Kavinilaa
 
Compilation
CompilationCompilation
Compilation
magansandu
 
Relational Database and Relational Algebra
Relational Database and Relational AlgebraRelational Database and Relational Algebra
Relational Database and Relational Algebra
Pyingkodi Maran
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
Amin Omi
 
relational algebra and it's implementation
relational algebra and it's implementationrelational algebra and it's implementation
relational algebra and it's implementation
dbmscse61
 
[Www.pkbulk.blogspot.com]dbms06
[Www.pkbulk.blogspot.com]dbms06[Www.pkbulk.blogspot.com]dbms06
[Www.pkbulk.blogspot.com]dbms06
AnusAhmad
 
CHAPTER 2 DBMS IN EASY WAY BY MILAN PATEL
CHAPTER 2 DBMS IN EASY WAY BY  MILAN PATELCHAPTER 2 DBMS IN EASY WAY BY  MILAN PATEL
CHAPTER 2 DBMS IN EASY WAY BY MILAN PATEL
Shashi Patel
 
Realtime Analytics
Realtime AnalyticsRealtime Analytics
Realtime Analytics
eXascale Infolab
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
Edward Blurock
 
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweqdbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
wrushabhsirsat
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
ImXaib
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
BALAMURUGANK63
 
R Algebra.ppt
R Algebra.pptR Algebra.ppt
R Algebra.ppt
Faisal143524
 
14285 lecture2
14285 lecture214285 lecture2
TDC2016SP - Trilha Frameworks JavaScript
TDC2016SP - Trilha Frameworks JavaScriptTDC2016SP - Trilha Frameworks JavaScript
TDC2016SP - Trilha Frameworks JavaScript
tdc-globalcode
 

Similar to [Www.pkbulk.blogspot.com]dbms04 (20)

Lecture5
Lecture5Lecture5
Lecture5
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational model
 
Data Base Management system relation algebra ER diageam Sql Query -nested qu...
Data Base Management system relation algebra ER diageam Sql Query -nested  qu...Data Base Management system relation algebra ER diageam Sql Query -nested  qu...
Data Base Management system relation algebra ER diageam Sql Query -nested qu...
 
DDL,DML,1stNF
DDL,DML,1stNFDDL,DML,1stNF
DDL,DML,1stNF
 
sfdfds
sfdfdssfdfds
sfdfds
 
1695304562_RELATIONAL_ALGEBRA.pdf
1695304562_RELATIONAL_ALGEBRA.pdf1695304562_RELATIONAL_ALGEBRA.pdf
1695304562_RELATIONAL_ALGEBRA.pdf
 
Compilation
CompilationCompilation
Compilation
 
Relational Database and Relational Algebra
Relational Database and Relational AlgebraRelational Database and Relational Algebra
Relational Database and Relational Algebra
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
relational algebra and it's implementation
relational algebra and it's implementationrelational algebra and it's implementation
relational algebra and it's implementation
 
[Www.pkbulk.blogspot.com]dbms06
[Www.pkbulk.blogspot.com]dbms06[Www.pkbulk.blogspot.com]dbms06
[Www.pkbulk.blogspot.com]dbms06
 
CHAPTER 2 DBMS IN EASY WAY BY MILAN PATEL
CHAPTER 2 DBMS IN EASY WAY BY  MILAN PATELCHAPTER 2 DBMS IN EASY WAY BY  MILAN PATEL
CHAPTER 2 DBMS IN EASY WAY BY MILAN PATEL
 
Realtime Analytics
Realtime AnalyticsRealtime Analytics
Realtime Analytics
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
 
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweqdbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
dbms-unit-_part-1.pptxeqweqweqweqweqweqweqweq
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
 
R Algebra.ppt
R Algebra.pptR Algebra.ppt
R Algebra.ppt
 
14285 lecture2
14285 lecture214285 lecture2
14285 lecture2
 
TDC2016SP - Trilha Frameworks JavaScript
TDC2016SP - Trilha Frameworks JavaScriptTDC2016SP - Trilha Frameworks JavaScript
TDC2016SP - Trilha Frameworks JavaScript
 

More from AnusAhmad

[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms10
[Www.pkbulk.blogspot.com]dbms10[Www.pkbulk.blogspot.com]dbms10
[Www.pkbulk.blogspot.com]dbms10
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms09
[Www.pkbulk.blogspot.com]dbms09[Www.pkbulk.blogspot.com]dbms09
[Www.pkbulk.blogspot.com]dbms09
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms02
[Www.pkbulk.blogspot.com]dbms02[Www.pkbulk.blogspot.com]dbms02
[Www.pkbulk.blogspot.com]dbms02
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms01
[Www.pkbulk.blogspot.com]dbms01[Www.pkbulk.blogspot.com]dbms01
[Www.pkbulk.blogspot.com]dbms01
AnusAhmad
 
[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13
AnusAhmad
 
9. java server faces
9. java server faces9. java server faces
9. java server faces
AnusAhmad
 
8. java script
8. java script8. java script
8. java script
AnusAhmad
 
7. struts
7. struts7. struts
7. struts
AnusAhmad
 
5. servlets
5. servlets5. servlets
5. servlets
AnusAhmad
 
4. jsp
4. jsp4. jsp
4. jsp
AnusAhmad
 
3. applets
3. applets3. applets
3. applets
AnusAhmad
 
2. http, html
2. http, html2. http, html
2. http, html
AnusAhmad
 
1. intro
1. intro1. intro
1. intro
AnusAhmad
 
6. hibernate
6. hibernate6. hibernate
6. hibernate
AnusAhmad
 

More from AnusAhmad (20)

[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing[Www.pkbulk.blogspot.com]file and indexing
[Www.pkbulk.blogspot.com]file and indexing
 
[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12
 
[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11[Www.pkbulk.blogspot.com]dbms11
[Www.pkbulk.blogspot.com]dbms11
 
[Www.pkbulk.blogspot.com]dbms10
[Www.pkbulk.blogspot.com]dbms10[Www.pkbulk.blogspot.com]dbms10
[Www.pkbulk.blogspot.com]dbms10
 
[Www.pkbulk.blogspot.com]dbms09
[Www.pkbulk.blogspot.com]dbms09[Www.pkbulk.blogspot.com]dbms09
[Www.pkbulk.blogspot.com]dbms09
 
[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07[Www.pkbulk.blogspot.com]dbms07
[Www.pkbulk.blogspot.com]dbms07
 
[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05
 
[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03[Www.pkbulk.blogspot.com]dbms03
[Www.pkbulk.blogspot.com]dbms03
 
[Www.pkbulk.blogspot.com]dbms02
[Www.pkbulk.blogspot.com]dbms02[Www.pkbulk.blogspot.com]dbms02
[Www.pkbulk.blogspot.com]dbms02
 
[Www.pkbulk.blogspot.com]dbms01
[Www.pkbulk.blogspot.com]dbms01[Www.pkbulk.blogspot.com]dbms01
[Www.pkbulk.blogspot.com]dbms01
 
[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13
 
9. java server faces
9. java server faces9. java server faces
9. java server faces
 
8. java script
8. java script8. java script
8. java script
 
7. struts
7. struts7. struts
7. struts
 
5. servlets
5. servlets5. servlets
5. servlets
 
4. jsp
4. jsp4. jsp
4. jsp
 
3. applets
3. applets3. applets
3. applets
 
2. http, html
2. http, html2. http, html
2. http, html
 
1. intro
1. intro1. intro
1. intro
 
6. hibernate
6. hibernate6. hibernate
6. hibernate
 

Recently uploaded

Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 

Recently uploaded (20)

Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 

[Www.pkbulk.blogspot.com]dbms04

  • 1. Relational Algebra 1 Fall 2001 Database Systems 1 Relational Algebra • A relation is a set of tuples. Each relational algebra operation takes as input a list of relations and produces a single relation. • General form: OperatorArguments (List of Relations)   New Relation • After each operation, the remaining attributes are carried to the new relation. The attributes may be renamed, but their domain remains the same. Fall 2001 Database Systems 2 Set Theoretic Operations • Regular set operations on relations • A set operation requires two participating relations R and S to be compatible – R and S should have the same attributes • R(Name:D1, Email:D2) • S(Name:D1, Email:D2, Address:D3) • T(Name:D1, Email:D4) • V(Name:D1, Email:D2) Which relations above are union (set operation) compatible? – Union compatibility may require type conversion (casting).
  • 2. Relational Algebra 2 Fall 2001 Database Systems 3 Set Operations  ¢¡¤£¦¥ §©¨£ ¥¡ ! #¤$%¥(')0¥$¡1$) 243©5 673 SR ∪ 8 9 @BADC7E F©GIHQP©RDHSR©T¤F F 5H QPUFVT 5 3 8 6 T 9 W 3 H¤FVTGQFVXYH 56 V3 SR ∩ 8 9 @BADC7E F©GIHQP©RDHSR©T¤F ` 6 HDP 5 3 8aR 3Yb 9 c 5d Qd FVT¤F 3 XQF SR − 8 9 @BADC7E F©GIHQP©RDHSR©T¤F 5 3 8e`¦AQH 36 H 5 3 9 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii Fall 2001 Database Systems 4 pYq¢rs0t%u pQvw r¤x€y¤ ‚yx0vƒ „Y… †(‡Yˆ‰  Smith@aol.com „Y‘ ’“€”€•—– Johns@geocities.com ˜™ d0e “gf)• Brown@netmail.com ˜h i1e j—k Gray@microsoft.com l0m)n)o0p0q l‚r s0tu vw‚xy o0x w0tz {%| })~  € Gray@microsoft,com {% ‚‚ƒ‚„g…‚~ † ‡ Robert432@aol.com {0ˆ ‰ƒgŠ‚‹—‡ Johns@somewhere.com {€Œ ‰—‡ ƒg‹ Jj@yahoo.com {0 Ž(g—… Duke@jazz.com‘g’¤“0”Q• ‘0–— ˜Q–— ™š‚›œ —–ž—Ÿ  g¡ œ ¢g£gž š€Ÿ—–£g¤ ¥%¦ §Y¦ ¨)© ª‚«¬‚­ ®€¯€­ ° ¯g± ¥%² §Y² ³1´µgµ€´± ¶U®%´· ¸ ¹ ¯gº—­ ° ¯€± ¥0» §Y² ¼¬%«¬‚­ © ¯gµ—¬ ½¤¬€¾¦¿¯€· À ¥€Á §» ‚¯gäµ—ª—­ ­ ³ª‚« «ª—­ Ä0Å ÆÇ ÈÉ Ê€Ëg̤͂ʂΗςРɀÑÒ Ó—Ô Ô Ê ÕÖ Ó—× ×—Ø Ö Ä0Ù ÆYÚ Æ¤Û€ÑË—ÜÝÉ€ÑÛ Ö Þ Ê€Ô × Êgß à‚áâ%ã à%äå â%æ€ç è á‚äå à0é—êgá€å ë1ì¤í—égî ç ï0ðñ%ò ó0ô—õ€ö ÷%ò ïø òù ï0ðñ%ø ó0ô—õ€ö ÷gú ï%ù û0ù ï0ðñ0õ ó0ô—õ%ò ÷%ò ï€ú òó ï0ðñgú ü%ôgò ÷0ù ï%ù ý%ù ï0ðñ0ù ü%ôgò ÷%ò ïø øgö ï0ðñ0û ü%ôgø ÷gú ï€ú ý‚ö ï0ðñ‚ý ü%ôgø ÷%ø ïò ú ï0ðñ0ó ü%ô—õ ÷%ø ï%õ ù
  • 3. Relational Algebra 3 Fall 2001 Database Systems 5 Assignment and Alias • Given a relation R, head(R)=A1…An is the list of attributes in R. • For each attribute, dom(A) gives the domain of A, name(A) gives the name of the attribute • Suppose B1…Bn is a list of attributes such that for each i, dom(Bi) = dom(Ai) Then assignment (:=) changes the names of some or all of the attributes in R and results in a new relation S, S(B1…Bn) := R(A1…An) and dom(B1) = dom(A1) … dom(Bn) = dom(An). Fall 2001 Database Systems 6 Set Operations • Find all people who are registered as buyers or owners  ¢¡¤£¦¥¨§© ! ! # $% ')(10 243 Smith@aol.com $65 798@3¤ACB Johns@geocities.com DE% F¦GIHCP Gray@microsoft.com QRQRQ QRQ@Q QRQRQ BUYERS-2(oid,name,email) := BUYERS(buyid,name,email) RESULT := BUYERS-2 ∪ OWNERS
  • 4. Relational Algebra 4 Fall 2001 Database Systems 7 Set Operations • Find all people who are owners but not buyers  ¢¡¤£¦¥¨§© ! !¤ # $% ')(0 132 Smith@aol.com $4 5768293@ Johns@geocities.com $¨A B¦CED3F Gray@microsoft.com G G G BUYERS-2(oid,name,email) := BUYERS(buyid,name,email) RESULT:= OWNERS - BUYERS-2 Fall 2001 Database Systems 8 Set Operations • Find all people who are both owners and buyers HPI7QSRUTV WYX ` acb7dUe e7dUbfXhg BUYERS-2(oid,name,email) := BUYERS(buyid,name,email) RESULT := OWNERS ∩ BUYERS-2
  • 5. Relational Algebra 5 Fall 2001 Database Systems 9 Projection • Select all tuples from relation R, restrict each tuple to the input attributes – written as R[A1…An] or for attributes A1…An from R – meaning nAA ...1 π for each tuple in R construct a new tuple containing only attributes A1…An place the new tuple in the result end-for remove duplicate tuples to preserve the set property Fall 2001 Database Systems 10 Projection • Find the names and email addresses of people who are both buyers and owners  ¢¡¤£¦¥¨§© !# $%('0) G ra y @ m ic ro s o ft.c o m RESULT:= OWNERS[name,email] ∩ BUYERS[name,email]
  • 6. Relational Algebra 6 Fall 2001 Database Systems 11 Projection • Find all the items on which at least one bid was placed  ¢¡¤£¦¥¨§© ! # RESULT := BIDS[iid] Fall 2001 Database Systems 12 Selection • Select certain tuples from a relation R based on a boolean condition C – written as R where C or – meaning: RCσ for each tuple t in R if t makes C true then return t in the resulting relation end-for
  • 7. Relational Algebra 7 Fall 2001 Database Systems 13 Selection • The selection condition C is built of – atomic conditions of the form Ai ∝ Aj or Ai ∝ c where • Ai, Aj are attributes and c is a constant of the same domain of values, and • ∝ is a comparison predicate of the form: =, , , = , = , etc. • If C1, C2 are selection conditions, then so are • C1 AND C2 • C1 OR C2 • NOT C1 Fall 2001 Database Systems 14 Selection • Find the bid identifiers of bids for item number “I1”:  ¢¡¤£¦¥¨§© ! $# ¤% I1-BIDS := BIDS WHERE iid = “I1” RESULT := I1-BIDS[bid]
  • 8. Relational Algebra 8 Fall 2001 Database Systems 15 Selection • Find the bid identifiers of bids for item number “I1” that are strictly more than $15. I1-BIDS := BIDS WHERE iid = “I1” AND amount 15 RESULT := I1-BIDS[bid]  ¢¡¤£¦¥¨§© ! # Fall 2001 Database Systems 16 Selection • Find the dates in which a bid for item number “I1” or “I5” was placed I1orI5-BIDS := BIDS WHERE iid = “I1” OR iid = “i5” RESULT := I1orI5-BIDS[date] $%('#)¤021 3542687 9A@2BDC 9A@2BFE G(@HE
  • 9. Relational Algebra 9 Fall 2001 Database Systems 17 Cartesian Product • Multiply the relations R and S, producing |R|x|S| many tuples with attributes head(R)+head(S) • Cartesian product combines two relations into one “big” relation • meaning for each tuple r in R do for each tuple s in S do compute a new tuple containing all attributes in r and s end-for end-for Fall 2001 Database Systems 18 R := Bids WHERE Amount 20 T := Items WHERE oid=“O2” S := T[iid,name] P := R X S   ¡£¢ ¤ ¥§¦©¨ ¢ ¤ ¡¤ !#©$¨ % '( )0213 465 %7 8£7 % '5 9@0A 47 %7 BC7 % '@8 9@02( 465 %5 B3 D EF G HPIQSR T@U VXW Y2YW `badc£W egf h@i p£q£r qstuY6q v w§x€y‚ ƒ w§x „£…†b‡ w§x ˆ ƒ w‰x€y2g‘2ˆ6ƒ w§x ’§“X”•–† —Sx ˆ ƒ —Sx ˜#…©“X‡ ™d e@f g2h6i6j kl ™m n‚m k2f oCd pp©d qgr ™d ste ™d e©l u2h©v k2m ™m w@m k2f oCd pp©d qgr ™d ste ™d en u2h©f kl ™l wj k2f oCd pp©d qgr ™d ste ™d e@f g2h6i6j kl ™m n‚m k©i x‚y@zy©{b|–}2pgy ™d e©l u2h©v k2m ™m w@m k©i x‚y@zy©{b|–}2pgy ™d en u2h©f kl ™l wj k©i x‚y@zy©{b|–}2pgy
  • 10. Relational Algebra 10 Fall 2001 Database Systems 19 Relational Algebra - Join • For all pairs of tuples r and s from relations R and S where Head(R)=A1…AnB1…Bk and Head(S)=B1…BkC1…Cm such that r[B1…Bk] = s[B1…Bk], include a tuple in R  ¢¡ S with attributes A1…AnB1…BkC1…Cm • The attributes in common between the two relations (B1…Bk) are called the “join attributes” • The join is a cartesian product followed by a selection on the join attributes, and a projection to remove the duplication of the join attributes [formally: you have to rename the join attributes in one relation so that you can express the selection/projection operations] Also called equijoin since the main criteria is the equality of join attributes Fall 2001 Database Systems 20 Relational Algebra - Join • Find all people with the same name and email address from the “buyers” and “owners” relations – join attributes are “Name” and “Email” from the buyer and owners relations – the joined relation will have attributes “Buyid, Name, Email, Oid” – there are 5 × 4 pairs of tuples to compare on the attributes “Name” and “Email” £¥¤§¦©¨ ¥ ¨¥ £!$#%' )(1032 ¨ 03( %54 %' 67 8@9BADC G r a y @ m ic ro s o ft,c o m E3F
  • 11. Relational Algebra 11 Fall 2001 Database Systems 21 Relational Algebra - Join  ¢¡¤£¦¥¢§¢¨  ¢© Gray@microsoft,com !# $% Smith@aol.com #')(10323 45 6¤798A@B Johns@geocities.com 4DC)E#F¢GIH PDQ RASUTWVYX Brown@netmail.com `badcDegf3h iqp r¤sUtvu Gray@microsoft.com ixw€ybA‚¢ƒ „¢…¤†¦‡¢ˆ¢‰ „¢ ‘’“” Gray@microsoft,com „¢…¤†¦‡¢ˆ¢‰ „¢ ‘’“” Gray@microsoft,com •¢–¤—¦˜¢™¢d •¢e fghi Gray@microsoft,com Example below shows four of the twenty pairs of tuples considered for the join Fall 2001 Database Systems 22 Relational Algebra - Join • Find the names of items with bids over $20 • Find the names of the owners of items with bids over $20 and are located in Boston Temp1 := Bids WHERE Amount 20 Temp2 := Items jlk Temp1 Result := Temp2[Name] Temp1 := Bids WHERE Amount 20 Temp3 := Items WHERE Location = “Boston” Temp2 := Temp3 jlk Temp1 Temp4 := Temp2 jlk Owners Result := Temp4[Owners.Name]
  • 12. Relational Algebra 12 Fall 2001 Database Systems 23 Relational Algebra - Division • Let head(R)=A1…AnB1…Bk and head(S)= B1…Bk • R ÷ S is the “maximal” set of tuples from R[A1…An] such that R contains all tuples in (R ÷ S) x S. • Division is often used for “for-all” queries, e.g. “Find tuples in R that are in a relation with ‘all’ tuples in S.” • All the attributes in the dividing relation S must exist in the divided relation R! for all tuples r in R[A1…An] if for all tuples s in S, r+s is in R place r in R ÷ S end-if end-for Fall 2001 Database Systems 24 Relational Algebra - Division   ¡ ¢ £ ¤¦¥ §¨¥ ©¥ ¤ §¨¥ ©¥ ¤¦¥ § ©¥ ¤¦¥ § © ¤ §¨¥ © ¤¦¥ § © ¤¦¥ § © ¤¦¥ §¨¥ © ! $# $% ' ( )10 230 4 5 6 798 @38 7BA @38 Find: • R ÷ S • R ÷ V • R ÷ Y C DEGFIH¦PQSR TUR VXW ÷ S
  • 13. Relational Algebra 13 Fall 2001 Database Systems 25 Relational Algebra - Division   ¡ ¢ £ ¤¦¥ §¨¥ ©¥ ¤ §¨¥ ©¥ ¤¦¥ § ©¥ ¤¦¥ § © ¤ §¨¥ © ¤¦¥ § © ¤¦¥ § © ¤¦¥ §¨¥ © ! $# $% ' ( )10 230 4 5 6 798 @38 7BA @38 Find: • R ÷ S • R ÷ V • R ÷ Y Fall 2001 Database Systems 26 Relational Algebra - Division • Find identifiers of buyers who placed a bid on “all” the items • Find the identifiers of items that have a bid from “all” the buyers Temp := Items[Iid] Temp1:= Bids[Buyid,Iid] Result := Temp1 ÷ Temp A := Buyers[BuyId] B := Bids[Iid, BuyId] Result := B ÷ A
  • 14. Relational Algebra 14 Fall 2001 Database Systems 27 Relational Algebra Operations – Union R ∪ S – Intersection R ∩ S – Difference R - S – Assignment S(B1…Bn) := R(A1…An) – Selection R where C – Projection R[A1…An] – Cartesian Product R x S – Join R  ¢¡ S – Division R ÷ S Fall 2001 Database Systems 28 £¥¤§¦¥¨© £¥ ¦ !!# $¥% (')021 Smith@aol.com $¥3 465718@9 Johns@geocities.com $A BC@5EDF8 Brown@netmail.com $ G H(CPIRQ Gray@microsoft.com S!TFU(VWX SY2`bac d¥ef g Vfe!ah ibp qsrut2v Gray@microsoft,com iw xy7€7!r@‚Pƒ Robert432@aol.com i„ …6y7†‡Pƒ Johns@somewhere.com i7ˆ …6tRƒRy!‡ Jj@yahoo.com i‰ (‘E’@ Duke@jazz.com “R”F•–— “˜™ de˜™ f gEh(i j2kRl2g2m ˜ kon p7q req sbtuuvwRx yEz@x@{Pz7| p7} re} ~6€R€o|u y‚„ƒ … zo†PxP{Pz7| pE‡ re} ˆ!wvwox2t@zR€@w ‰FwoŠ ‹zR‚@Œ 2Ž  ‘7’o“s”@•2–P– —!•˜˜•@– E™ FŽ š› 2’Rœ2 ž’oŸR 7¡ ›R¢£u•2–P–@’ ¤!¥ •@¦P¦o˜¥ o§ e¨ ›R¢” ¥ © ’@–@¦P’7ª «!¬­(® «b¯° ­(±E²@³ ¬!¯° «´2µ¬E° ¶s· ¸7´E¹2² º»¼b½ ¾!¿7À7Á ½ ºÃ ½uÄ º»¼bà ¾!¿7À7Á ÂRÅ ºÄ ÆÄ º»¼À ¾!¿7À½ ½ º7Å ½„¾ º»¼Å Ç!¿½ ÂEÆ ºÄ ÈbÄ º»¼Ä Ç!¿½ ½ ºÃ ÃEÁ º»¼Æ Ç!¿Ã ÂRÅ º7Å È!Á º»¼!È Ç!¿Ã Âà º½ Å º»¼¾ Ç!¿7À Âà ºÀ Ä Auction Database
  • 15. Relational Algebra 15 Fall 2001 Database Systems 29 Problem 1 Find the name and email of owners of items located in “Boston” A := Items WHERE Location = “Boston” B := A  ¢¡ Owners Result := B[Owners.Name, Owners.Email] Fall 2001 Database Systems 30 Problem 2 Find the identifiers and amount of bids placed by buyer “Roberts” A := Buyers WHERE Name = “Roberts” B := A  ¢¡ Bids Result := B[Bid, Amount]
  • 16. Relational Algebra 16 Fall 2001 Database Systems 31 Problem 3 Find the names of buyers who placed a bid on an item owned by “Brown” A := Owners WHERE Name = “Brown” B := (A  ¢¡ Items) [Iid] C := B  ¢¡ Bids Result := (C  ¢¡ Buyers) [Buyers.Name] Fall 2001 Database Systems 32 Problem 4 Find the identifier of items with more than one bid A := Bids[Bid, Iid] B := A x Bids[Bid,Iid] C := B WHERE (A.Bid Bids.Bid) AND (A.Iid = Bids.Iid) Result := C[Iid]
  • 17. Relational Algebra 17 Fall 2001 Database Systems 33 Problem 5 Find the names of items all buyers placed a bid on A := (Bids[Iid, BuyId]) ÷ (Buyers[Buyid]) B := A  ¢¡ Items Result := B[Name]