Title: Initial QGM
1Initial QGM
2Q1.CDeptmgmt AndQ1.GradegtQ2.1
SELECT Q1.SName FROM took Q1, temp1 Q2 WHERE
Q1.CDept mgmt AND Q1.Grade gt
Q2.1
Q2
Q1
Grade
SName, CName, CDept, Grade
temp1
SELECT Max(Grade) AS Grade FROM Child Q4
Q4
Max
Grade
took
SELECT Grade FROM took Q3 WHERE
Q3.CNameQ1.CName
Q3
CName, Grade
took
3Performing Feed for the topmost Box
4supp
Q1.GradegtQ2.1
SELECT Q1.SName FROM took Q1, temp1 Q2 WHERE
Q1.Grade gt Q2.1
Q2
Q1
Grade
SName, CName, Grade
temp1
SELECT MAX (Grade) AS Grade FROM Child
Q4
Max
CDeptmgmt
SELECT DISTINCT CName FROM supp
distinct
SName, CName, CDept, Grade
Magic_1
took
5supp
Q1.GradegtQ2.1
SELECT Q1.SName FROM took Q1, CIBox Q2 WHERE
Q1.Grade gt Q2.1
Q2
Q1
SName, CName, Grade
SELECT Q3.Grade FROM DCOBox Q3 WHERE Q3.CName
Q1.CName
Q3
Q3.CNameQ1.CName
CIBox
CName
CName
CName,Grade
CDeptmgmt
distinct
Q4
Q5
SELECT Q4.cName, Q5.1FROM Magic_1 Q4,
temp1 Q5
SName, CName, CDept, Grade
DCOBox
Grade
Magic_1
Q6
took
temp1
Max
6Can merge the C1Box and the topmost box into one
box as every tuple in the topmost box joins with
atmost one tuple in the C1Box
7supp
Q1.GradegtQ2.Grade Q1.cNameQ2.cName
SELECT Q1.sName FROM supp Q1, DCOBox Q2WHERE
Q1.cNameQ2.cName AND Q1.GradegtQ2.Grade
Q2
Q1
SName, CName, Grade
CName,Grade
CName
CName
CDeptmgmt
SELECT Q4.cName,Q5.1FROM Magic_1 Q4,
temp1 Q5
distinct
Q4
Q5
SName, CName, CDept, Grade
DCOBox
Grade
Magic_1
Q6
took
temp1
Max
8Starting Point for the Aggregation Box
9CName, Grade
Q4
Q5
SELECT Q4.CName, Q5.1 AS Grade FROM Magic_1 Q4,
temp1 Q5
DCOBox
Grade
CName
temp1
SELECT Max(Grade) AS Grade FROM Child Q6
Q6
Max
distinct
Grade
Magic_1
Q4.CNameQ3.CName
Q3
SELECT Grade FROM took Q3 WHERE
Q3.CNameQ1.CName
CName, Grade
took
10Performing Feed for the aggregate Box
11CName, Grade
SELECT Q4.CName,Q5.1 From Magic_1 Q4,
temp1 Q5
Q4
Q5
DCOBox
Grade
CName
SELECT Max(Grade) AS Grade FROM Child Q6
Q6
Max
temp1
Grade
SELECT Grade FROM DCOBox Q7 WHERE Q7.CName
Q4.CName
distinct
Q7.cNameQ4.cName
Q7
CIBox
CName
CName, Grade
Magic_1
Q8
Q9
SELECT Q8.CName, Q9.Grade FROM Magic_2 Q8, Child
Q9
DCOBox
Grade
SELECT Grade FROM took Q3 WHERE Q3.CName
Q1.CName
CName
Q1.CNameQ3.CName
Q3
distinct
CName, Grade
Magic_2
took
12Performing Absorb for the aggregate Box
introduce the Group By and the LOJ
13CName, Grade
Q4
Q5
DCOBox
SELECT Q4.CName, Q5.Grade FROM Magic_1 Q4 LOJ
temp1 Q5 ON CName
CName, Grade
SELECT CName, MAX (Grade) AS GradeFROM Child
Q6GROUPBY Q6.CName
CName
Max
Q6
temp1
CName, Grade
distinct
Q7
CIBox
CName
CName, Grade
Magic_1
Q8
Q9
DCOBox
Grade
CName
Q1.cNameQ3.cName
Q3
distinct
CName, Grade
Magic_2
took
14The LOJ is unnecessary here, and the C1Box is
also unnecessary.
15Q1.GradegtQ2.Grade Q1.CNameQ2.CName
SELECT Q1.SName FROM supp Q1, temp1 Q2 WHERE
Q1.CName Q2.CName AND Q1.Grade
gt Q2.Grade
Q2
Q1
CName, Grade
SELECT CName, MAX (Grade) AS GradeFROM Child
Q6GROUPBY Q6.CName
Q6
temp1
Max
CName, Grade
Q8
Q9
DCOBox
Grade
CName
Q1.CNameQ3.CName
Q3
distinct
CName, Grade
Magic_2
took
16Starting Point for the bottommost SPJ Box
17CName, Grade
SELECT Q8.CName, Q9.Grade FROM Magic_2 Q8, temp2
Q9
Q8
Q9
DCOBox
Grade
CName
temp2
Q8.CNameQ3.CName
Q3
SELECT Grade FROM took Q3 WHERE Q3.CName
Q1.CName
distinct
CName, Grade
took
Magic_2
18Performing Absorb for the SPJ Box
19CName, Grade
SELECT Q9.CName, Q9.Grade FROM temp2 Q9
Q8
Q9
DCOBox
CName, Grade
CName
temp2
Q10.CNameQ3.CName
Q3
Q10
SELECT Q3.CName, Q3.Grade FROM Magic_2 Q10, took
Q3 WHERE Q3.CName Q10.CName
distinct
CName
CName, Grade
took
Magic_2
20Remove unnecessary DCOBox
21CName, Grade
SELECT Q3.CName, Q3.Grade FROM Magic_2 Q10, took
Q3 WHERE Q3.CName Q10.CName
Q10.cNameQ3.cName
Q3
Q10
distinct
CName
CName, Grade
took
Magic_2
22The Final QGM
23Q1.GradegtQ2.Grade Q1.CNameQ2.CName
SELECT Q1.sName FROM supp Q1, temp1 Q2WHERE
Q1.CNameQ2.CName AND Q1.GradegtQ2.Grade
Q2
Q1
SName, CName, Grade
CName, Grade
SELECT CName, MAX (Grade) AS GradeFROM Child
Q6GROUPBY Q6.CName
temp1
Q6
Max
CDeptmgmt
CName, Grade
SName, CName, CDept, Grade
CName
Q10.CNameQ3.CName
Q3
Q10
SELECT Q3.CName, Q3.Grade FROM Magic_2 Q10, took
Q3 WHERE Q3.CName Q10.CName
distinct
took
CName
CName, Grade
took
Magic_2