slides5 - Schedule Today Jan 17(TH x x Relational Algebra...

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

View Full Document Right Arrow Icon
Winter 2002 Arthur Keller – CS 180 5–1 Schedule Today: Jan. 17 (TH) Relational Algebra. Read Chapter 5. Project Part 1 due. Jan. 22 (T) SQL Queries. Read Sections 6.1-6.2. Assignment 2 due. Jan. 24 (TH) Subqueries, Grouping and Aggregation. Read Sections 6.3-6.4. Project Part 2 due. Jan. 29 (T) Modifications, Schemas, Views. Read Sections 6.5-6.7. Assignment 3 due.
Image of page 1

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

View Full Document Right Arrow Icon
Winter 2002 Arthur Keller – CS 180 5–2 “Core” Relational Algebra A small set of operators that allow us to manipulate relations in limited but useful ways. The operators are: 1. Union, intersection, and difference: the usual set operators. But the relation schemas must be the same. 2. Selection : Picking certain rows from a relation. 3. Projection : Picking certain columns. 4. Products and joins : Composing relations in useful ways. 5. Renaming of relations and their attributes.
Image of page 2
Winter 2002 Arthur Keller – CS 180 5–3 Relational Algebra limited expressive power (subset of possible queries) good optimizer possible rich enough language to express enough useful things Finiteness σ SELECT PROJECT π X CARTESIAN PRODUCT FUNDAMENTAL U UNION BINARY – SET-DIFFERENCE SET-INTERSECTION θ THETA-JOIN CAN BE DEFINED NATURAL JOIN IN TERMS OF ÷ DIVISION or QUOTIENT FUNDAMENTAL OPS UNARY
Image of page 3

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

View Full Document Right Arrow Icon
Winter 2002 Arthur Keller – CS 180 5–4 Extra Example Relations DEPOSIT(branchName, acctNo, custName,balance) CUSTOMER(custName, street,custCity) BORROW(branchName,loan-no, custName,amount) BRANCH(branchName, assets, branchCity) CLIENT(custName, emplName) Borrow BN L# CN AMT T1 Midtown 123 Fred 600 T2 Midtown 234 Sally 1200 T3 Midtown 235 Sally 1500 T4 Downtown 612 Tom 2000
Image of page 4
Winter 2002 Arthur Keller – CS 180 5–5 Selection R 1 = σ C ( R 2 ) where C is a condition involving the attributes of relation R 2 . Example Relation Sells : JoeMenu = σ bar=Joe's ( Sells ) bar beer price Joe's Bud 2.50 Joe's Miller 2.75 Sue's Bud 2.50 Sue's Coors 3.00 bar beer price Joe's Bud 2.50 Joe's Miller 2.75
Image of page 5

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

View Full Document Right Arrow Icon
Winter 2002 Arthur Keller – CS 180 5–6 SELECT ( σ ) arity( σ (R)) = arity(R) 0 card( σ (R)) card(R) σ c (R) σ c (R) (R) c is selection condition: terms of form: attr op value attr op attr op is one of < = > ≠≥ example of term: branch-name = ‘Midtown’ terms are connected by ∧ ∨ ¬ σ branchName = ‘Midtown’ amount > 1000 (Borrow) σ custName = empName (client)
Image of page 6
Winter 2002 Arthur Keller – CS 180 5–7 Projection R 1 = π L ( R 2 ) where L is a list of attributes from the schema of R 2 . Example π beer,price ( Sells ) Notice elimination of duplicate tuples. beer price Bud 2.50 Miller 2.75 Coors 3.00
Image of page 7

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

View Full Document Right Arrow Icon
Winter 2002 Arthur Keller – CS 180 5–8 Projection   ( ) 0 π card ( π A (R)) card (R) arity ( π A (R)) = m arity(R) = k π i 1 ,...,i m (R) 1 i j k distinct produces set of m-tuples a 1 ,...,a m such that 5 k-tuple b 1 ,...,b k in R where a j = b i j for j = 1,...,m π branchName, custName (Borrow) Midtown Fred Midtown Sally Downtown Tom
Image of page 8
Winter 2002 Arthur Keller – CS 180 5–9 Product R = R 1 × R 2 pairs each tuple t 1 of R 1 with each tuple t 2 of R 2 and puts in R a tuple t 1 t 2 .
Image of page 9

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

View Full Document Right Arrow Icon
Winter 2002 Arthur Keller – CS 180 5–10 Cartesian Product ( × )
Image of page 10
Image of page 11
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