{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

relational-algebra

relational-algebra - RelationalAlgebra BasicOperations...

This preview shows pages 1–12. Sign up to view the full content.

1 Relational Algebra Basic Operations Algebra of Bags

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

View Full Document
2 What is an “Algebra” Mathematical system consisting of: Operands  --- variables or values from  which new values can be constructed. Operators  --- symbols denoting procedures  that construct new values from given  values.
3 What is Relational Algebra? An algebra whose operands are  relations or variables that represent  relations. Operators are designed to do the most  common things that we need to do with  relations in a database. The result is an algebra that can be used  as a  query language   for relations.

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

View Full Document
4 Core Relational Algebra Union, intersection, and difference . Usual set operations, but  both operands  must have the same relation schema . Selection : picking certain rows. Projection : picking certain columns. Products  and  joins : compositions of  relations. Renaming  of relations and attributes.
5 Selection R1 :=  σ (R2) C   is a condition (as in “if” statements) that  refers to attributes of R2. R1 is all those tuples of R2 that satisfy  C .

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

View Full Document
6 Example : Selection Relation Sells: bar beer price Joe’s Bud 2.50 Joe’s Miller 2.75 Sue’s Bud 2.50 Sue’s Miller 3.00 JoeMenu :=  σ bar=“Joe’s” (Sells): bar beer price Joe’s Bud 2.50 Joe’s Miller 2.75
7 Projection R1 :=  π (R2)  is a list of attributes from the schema of  R2. R1 is constructed by looking at each tuple  of R2, extracting the attributes on list  L , in  the order specified, and creating from  those components a tuple for R1. Eliminate duplicate tuples, if any.

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

View Full Document
8 Example : Projection Relation Sells: bar beer price Joe’s Bud 2.50 Joe’s Miller 2.75 Sue’s Bud 2.50 Sue’s Miller 3.00 Prices :=  π beer,price (Sells): beer price Bud 2.50 Miller 2.75 Miller 3.00
9 Extended Projection Using the same  π L  operator, we allow  the list  L   to contain arbitrary  expressions involving attributes: 1. Arithmetic on attributes, e.g.,  A + B->C . 2. Duplicate occurrences of the same  attribute.

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

View Full Document
10 Example : Extended Projection R =  ( A B ) 1 2 3 4 π A + B->C , A , A  (R) = C A1 A2 3 1 1 7 3 3
11 Product R3 := R1  Χ  R2 Pair each tuple t1 of R1 with each tuple t2 of  R2.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern