Relational Algebra
Relational Algebra
Relational Algebra
Relational Query Languages
• Query languages: Allow manipulation and
retrieval of data from a database.
• Relational model supports simple, powerful
QLs:
– Strong formal foundation based on logic.
– Allows for much optimization.
Formal Relational Query
Languages
Two mathematical Query Languages form the
basis for “real” languages (e.g. SQL),
and for implementation:
Relational Algebra: More operational,
very useful for representing execution
plans.
R1 S1 =
R c S c ( R S)
• Result schema same as that of cross-
product.
• May have fewer tuples than cross-
product.
Boats
bid bname color
101 Interlake Blue
102 Interlake Red
103 Clipper Green
104 Marine Red
Find names of sailors who’ve reserved
boat #103
• Solution 1: sname (( Re serves) Sailors)
bid 103