slides5 - Schedule Today: Jan. 17 (TH) x x Relational...

Info iconThis preview shows pages 1–9. 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.
Background image of page 1

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

View Full DocumentRight 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.
Background 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
Background image of page 3

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

View Full DocumentRight 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
Background 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
Background image of page 5

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

View Full DocumentRight 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)
Background 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
Background image of page 7

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

View Full DocumentRight 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
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2011 for the course CS CS 180 taught by Professor Dr.arthur during the Fall '01 term at The University of Akron.

Page1 / 43

slides5 - Schedule Today: Jan. 17 (TH) x x Relational...

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

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