ra - Relational Algebra Basic Operations Algebra of Bags 1...

Info icon This preview shows pages 1–10. 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 iconThis 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 iconThis 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 := σ C (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 iconThis 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 := π L (R2) L 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 iconThis 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 .
Image of page 9

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

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