L07 - Relational Algebra

L07 - Relational Algebra - Relational Algebra Relational...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Relational Algebra Relational Algebra ¡ Procedural language ¡ Six basic operators ¢ select: σ ¢ project: ∏ ¢ union: ∪ ¢ set difference: – ¢ Cartesian product: x ¢ rename: ρ ¡ The operators take one or two relations as inputs and produce a new relation as a result. Select is a Select is a “ “ filtering filtering ” ” operation: operation: ¡ Suppose that we have a relation r: ¡ σ A=B ^ D > 5 (r) A B C D α α β β α β β β 1 5 12 23 7 7 3 10 A B C D α β α β 1 23 7 10 Select Select – – Formal textbook definition: Formal textbook definition: ¡ Notation: σ p ( r ) ¡ p is called the selection predicate ¡ Defined as: σ p ( r ) = { t | t ∈ r and p(t) } Where p is a formula in propositional calculus consisting of terms connected by : ∧ , ∨ , ¬ Each term is one of: <attribute> op <attribute> or <constant> where op is one of: =, ≠ , >, ≥ . <. ≤ ¡ Example of selection (using the textbook’s running example): σ branch_name=“Perryridge” ( account ) And in another scenario And in another scenario ---- ¡ Suppose that we have the relation boats from the marina example: ¡ What is the result of σ color=“green” (boats) bid name color 1 2 31 4 5 Rosey Jady Sunset Knight Spring green aqua red golden green bid name color 1 5 Rosey Spring green green Project is a Project is a “ “ culling culling ” ” operation: operation: A B C α α β β 10 20 30 40 1 1 1 2 ¡ Suppose that we have a relation r: ¡ ∏ A,C ( r ) A C α α β β 1 1 1 2 = A C α β β 1 1 2 Select Select – – Formal textbook definition: Formal textbook definition: ¡ Notation: ∏ A 1 , A 2 , …, A k (r) where A 1 , A 2 are attribute names and r is a relation name. ¡ The result is defined as the relation of k columns obtained by erasing the columns that are not listed ¡ Duplicate rows removed from result, since relations are sets ¡ Example: To eliminate the branch_name attribute of account ∏ account_number, balance ( account ) And another example from the marina scenario And another example from the marina scenario ---- ¡ Suppose we are trying to schedule service for boats and we want to know which boats are have reservations for them and when. Consider the reserves relation: ¡ Consider the result of ∏ bid, day (reserves) sid bid day 1 1 21 7 7 31 1 4 31 5 2007-03-01 2007-05-31 2007-05-01 2007-03-21 2007-03-01 bid day 31 1 4 31 5 2007-03-01 2007-05-31 2007-05-01 2007-03-21 2007-03-01 Union is a...
View Full Document

This note was uploaded on 04/08/2008 for the course EE 468 taught by Professor Conry during the Spring '08 term at Clarkson University .

Page1 / 25

L07 - Relational Algebra - Relational Algebra Relational...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online