november 9, 2015. query: “find the schedules and rooms of all courses taken by any math major.”...
DESCRIPTION
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 queryTRANSCRIPT
![Page 1: November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically: schedule, room ( major=‘Math’ ((Student](https://reader036.vdocuments.us/reader036/viewer/2022062306/5a4d1ad37f8b9ab05997211e/html5/thumbnails/1.jpg)
November 9, 2015
![Page 2: November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically: schedule, room ( major=‘Math’ ((Student](https://reader036.vdocuments.us/reader036/viewer/2022062306/5a4d1ad37f8b9ab05997211e/html5/thumbnails/2.jpg)
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 Temp1Temp1 JOIN Class GIVING Temp2SELECT Temp2 WHERE major=‘Math’ GIVING Temp3PROJECT Temp3 OVER schedule,
room
![Page 3: November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically: schedule, room ( major=‘Math’ ((Student](https://reader036.vdocuments.us/reader036/viewer/2022062306/5a4d1ad37f8b9ab05997211e/html5/thumbnails/3.jpg)
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
![Page 4: November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically: schedule, room ( major=‘Math’ ((Student](https://reader036.vdocuments.us/reader036/viewer/2022062306/5a4d1ad37f8b9ab05997211e/html5/thumbnails/4.jpg)
Same SQL statement can be translated to different relational algebra statements
Performing SELECT early reduces size of intermediate nodes-See next slide
![Page 5: November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically: schedule, room ( major=‘Math’ ((Student](https://reader036.vdocuments.us/reader036/viewer/2022062306/5a4d1ad37f8b9ab05997211e/html5/thumbnails/5.jpg)
Symbolically: schedule, room ((( major=‘Math’ (Student)) |x| Enroll) |x|
Class)
Relational algebra:
SELECT Student WHERE major=‘Math’
GIVING T1T1 JOIN Enroll GIVING T2T2 JOIN Class GIVING T3PROJECT T3 OVER schedule, room
![Page 6: November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically: schedule, room ( major=‘Math’ ((Student](https://reader036.vdocuments.us/reader036/viewer/2022062306/5a4d1ad37f8b9ab05997211e/html5/thumbnails/6.jpg)
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 T1SELECT T1 WHERE major=‘Math’ AND grade=‘F’
GIVING T2T2 JOIN Class GIVING T3PROJECT Temp3 OVER schedule, room
![Page 7: November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically: schedule, room ( major=‘Math’ ((Student](https://reader036.vdocuments.us/reader036/viewer/2022062306/5a4d1ad37f8b9ab05997211e/html5/thumbnails/7.jpg)
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 T1SELECT Enroll WHERE grade=‘F’ GIVING T2T1 JOIN T2 GIVING T3T3 JOIN Class GIVING T4PROJECT Temp4 OVER schedule, room
![Page 8: November 9, 2015. Query: “Find the schedules and rooms of all courses taken by any Math major.” Symbolically: schedule, room ( major=‘Math’ ((Student](https://reader036.vdocuments.us/reader036/viewer/2022062306/5a4d1ad37f8b9ab05997211e/html5/thumbnails/8.jpg)
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 T2SELECT Enroll WHERE grade=‘F’ GIVING T3T2 JOIN T3 GIVING T4PROJECT T4 OVER classNumber GIVING T5T5 JOIN Class GIVING T6PROJECT T6 OVER schedule, room