Presentation is loading. Please wait.

Presentation is loading. Please wait.

November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically:  schedule, room (  major=‘Math’ ((Student.

Similar presentations


Presentation on theme: "November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically:  schedule, room (  major=‘Math’ ((Student."— Presentation transcript:

1 November 9, 2015

2 Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically:  schedule, room (  major=‘Math’ ((Student |x| Enroll) |x| Class)) Relational algebra: Student JOIN Enroll GIVING Temp1 Temp1 JOIN Class GIVING Temp2 SELECT Temp2 WHERE major=‘Math’ GIVING Temp3 PROJECT Temp3 OVER schedule, room

3  An internal node can be executed when its operands are available  Node is replaced by the result of the operation it represents  Process continues until root node is reached  Root node is executed last, and is replaced by the result of the entire query

4  Same SQL statement can be translated to different relational algebra statements  Performing SELECT early reduces size of intermediate nodes-See next slide

5 Symbolically:  schedule, room (((  major=‘Math’ (Student)) |x| Enroll) |x| Class) Relational algebra: SELECT Student WHERE major=‘Math’ GIVING T1 T1 JOIN Enroll GIVING T2 T2 JOIN Class GIVING T3 PROJECT T3 OVER schedule, room

6 Query: “Find the schedules and rooms for all Math majors who received a grade of F.” Symbolically:  schedule, room ((  major=‘Math’ & grade=‘F’ (Student |x| Enroll)) |x| Class)) Relational algebra: Student JOIN Enroll GIVING T1 SELECT T1 WHERE major=‘Math’ AND grade=‘F’ GIVING T2 T2 JOIN Class GIVING T3 PROJECT Temp3 OVER schedule, room

7  Apply both selections to their corresponding tables before the join reduces the size of the intermediate tables Symbolically:  schedule, room (((  major=‘Math’ (Student)) |x| (  grade=‘F’ (Enroll))) |x| Class)) Relational algebra: SELECT Student WHERE major=‘Math’ GIVING T1 SELECT Enroll WHERE grade=‘F’ GIVING T2 T1 JOIN T2 GIVING T3 T3 JOIN Class GIVING T4 PROJECT Temp4 OVER schedule, room

8  Performing projections early will reduce the number of columns in the intermediate table SELECT Student WHERE major=‘Math’ GIVING T1 PROJECT T1 OVER stuId GIVING T2 SELECT Enroll WHERE grade=‘F’ GIVING T3 T2 JOIN T3 GIVING T4 PROJECT T4 OVER classNumber GIVING T5 T5 JOIN Class GIVING T6 PROJECT T6 OVER schedule, room


Download ppt "November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically:  schedule, room (  major=‘Math’ ((Student."

Similar presentations


Ads by Google