Week 2.pdf

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

View Full Document Right Arrow Icon
1 EECS 116 & CS 122A Discussion - Week 2
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 DIVISION OPERATION Notation: Suited to queries that include the phrase “for all”. Let r and s be relations on schemas R and S respectively where R = ( A 1 , …, A m , B 1 , …, B n ) S = ( B 1 , …, B n ) The result of r s is a relation on schema R S = ( A 1 , …, A m ) r s = { t | t   R-S ( r )   u s ( tu r ) } Where tu means the concatenation of tuples t and u to produce a single tuple r s
Image of page 2
3 DIVISION Simulate integer division: C = A B the largest integer such that C * B ≤ A In Relational Algebra C = A B the largest relation (# of tuples) such that C × B A
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 DIVISION EXAMPLE Relations Completed, DBProject : Completed DBProject : Completed DBProject Find all students who have completed all DB projects. For any x values in r , if x is associated with all y in s , this x value is in r ÷ s. Student Task Fred Database1 Fred Database2 Fred Compiler1 Eugene Database1 Eugene Compiler1 Sarah Database1 Sarah Database2 Task Database1 Database2 Student Fred Sarah
Image of page 4
5 EXERCISE Taught(crscode, semester , i_id) crscode, semester (Taught)   semester (Taught) Return those courses that have been taught in all semesters.
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 EXERCISE Find all customers who have an account at all branches located in Brook lyn city. customer_name, branch_name ( depositor account )   branch_name ( branch_city = “Brooklyn” ( branch ))
Image of page 6