{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

relational-algebra - RelationalAlgebra BasicOperations...

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

View Full Document Right Arrow Icon
1 Relational Algebra Basic Operations Algebra of Bags
Image of page 1

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

View Full Document Right Arrow Icon
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.
Image of page 2
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.
Image of page 3

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

View Full Document Right Arrow Icon
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.
Image of page 4
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 .
Image of page 5

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

View Full Document Right Arrow Icon
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
Image of page 6
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.
Image of page 7

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

View Full Document Right Arrow Icon
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
Image of page 8
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.
Image of page 9

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

View Full Document Right Arrow Icon
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
Image of page 10
11 Product R3 := R1  Χ  R2 Pair each tuple t1 of R1 with each tuple t2 of  R2.
Image of page 11

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

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern