230 likes | 314 Views
Initial QGM. Q1.CDept=‘mgmt’ And Q1.Grade>=Q2.$1. SELECT Q1.SName FROM took Q1, temp1 Q2 WHERE Q1.CDept = ‘mgmt’ AND Q1.Grade >= Q2.$1. Q2. Q1. Grade. SName, CName, CDept, Grade. temp1. Q4. SELECT Max(Grade) AS Grade FROM Child Q4. Max. Grade. took.
E N D
Q1.CDept=‘mgmt’ AndQ1.Grade>=Q2.$1 SELECT Q1.SName FROM took Q1, temp1 Q2 WHERE Q1.CDept = ‘mgmt’ AND Q1.Grade >= Q2.$1 Q2 Q1 Grade SName, CName, CDept, Grade temp1 Q4 SELECT Max(Grade) AS Grade FROM Child Q4 Max Grade took SELECT Grade FROM took Q3 WHERE Q3.CName=Q1.CName Q3 CName, Grade took
Q1.Grade>=Q2.$1 SELECT Q1.SName FROM took Q1, temp1 Q2 WHERE Q1.Grade >= Q2.$1 supp Q2 Q1 Grade SName, CName, Grade temp1 SELECT MAX (Grade) AS Grade FROM Child Q4 Max CDept=‘mgmt’ SELECT DISTINCT CName FROM supp distinct SName, CName, CDept, Grade Magic_1 took
Q1.Grade>=Q2.$1 SELECT Q1.SName FROM took Q1, CIBox Q2 WHERE Q1.Grade >= Q2.$1 supp Q2 Q1 SName, CName, Grade SELECT Q3.Grade FROM DCOBox Q3 WHERE Q3.CName = Q1.CName Q3 Q3.CName=Q1.CName CIBox CName CName CName,Grade CDept=‘mgmt’ distinct Q4 Q5 SELECT Q4.cName, Q5.$1FROM Magic_1 Q4, temp1 Q5 SName, CName, CDept, Grade DCOBox Grade Magic_1 Q6 temp1 took Max
Can 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
Q1.Grade>=Q2.Grade Q1.cName=Q2.cName SELECT Q1.sName FROM supp Q1, DCOBox Q2WHERE Q1.cName=Q2.cName AND Q1.Grade>=Q2.Grade supp Q2 Q1 SName, CName, Grade CName,Grade CName CName CDept=‘mgmt’ SELECT Q4.cName,Q5.$1FROM Magic_1 Q4, temp1 Q5 distinct Q4 Q5 SName, CName, CDept, Grade DCOBox Grade Magic_1 Q6 temp1 took Max
CName, 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.CName=Q3.CName Q3 SELECT Grade FROM took Q3 WHERE Q3.CName=Q1.CName CName, Grade took
CName, 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 temp1 Max Grade SELECT Grade FROM DCOBox Q7 WHERE Q7.CName = Q4.CName distinct Q7.cName=Q4.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.CName=Q3.CName Q3 distinct CName, Grade Magic_2 took
Performing Absorb for the aggregate Box – introduce the Group By and the LOJ
CName, Grade Q4 Q5 DCOBox SELECT Q4.CName, Q5.Grade FROM Magic_1 Q4 LOJ temp1 Q5 ON CName CName, Grade CName SELECT CName, MAX (Grade) AS GradeFROM Child Q6GROUPBY Q6.CName Max Q6 temp1 CName, Grade distinct Q7 CIBox CName CName, Grade Magic_1 Q8 Q9 DCOBox Grade CName Q1.cName=Q3.cName Q3 distinct CName, Grade Magic_2 took
The LOJ is unnecessary here, and the C1Box is also unnecessary.
Q1.Grade>=Q2.Grade Q1.CName=Q2.CName SELECT Q1.SName FROM supp Q1, temp1 Q2 WHERE Q1.CName = Q2.CName AND Q1.Grade >= 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.CName=Q3.CName Q3 distinct CName, Grade Magic_2 took
CName, Grade SELECT Q8.CName, Q9.Grade FROM Magic_2 Q8, temp2 Q9 Q8 Q9 DCOBox Grade CName temp2 Q8.CName=Q3.CName Q3 SELECT Grade FROM took Q3 WHERE Q3.CName = Q1.CName distinct CName, Grade took Magic_2
CName, Grade SELECT Q9.CName, Q9.Grade FROM temp2 Q9 Q8 Q9 DCOBox CName, Grade CName temp2 Q10.CName=Q3.CName Q10 Q3 SELECT Q3.CName, Q3.Grade FROM Magic_2 Q10, took Q3 WHERE Q3.CName = Q10.CName distinct CName CName, Grade took Magic_2
CName, Grade SELECT Q3.CName, Q3.Grade FROM Magic_2 Q10, took Q3 WHERE Q3.CName = Q10.CName Q10.cName=Q3.cName Q10 Q3 distinct CName CName, Grade took Magic_2
Q1.Grade>=Q2.Grade Q1.CName=Q2.CName SELECT Q1.sName FROM supp Q1, temp1 Q2WHERE Q1.CName=Q2.CName AND Q1.Grade>=Q2.Grade Q1 Q2 SName, CName, Grade CName, Grade temp1 SELECT CName, MAX (Grade) AS GradeFROM Child Q6GROUPBY Q6.CName Q6 Max CDept=‘mgmt’ CName, Grade SName, CName, CDept, Grade CName Q10.CName=Q3.CName Q10 Q3 SELECT Q3.CName, Q3.Grade FROM Magic_2 Q10, took Q3 WHERE Q3.CName = Q10.CName distinct took CName CName, Grade took Magic_2