0% found this document useful (0 votes)
366 views10 pages

Ans Assi2

1. The SQL query is simplified using idempotency rules to FALSE, so the transformed query returns SELECT ENO FROM ASG WHERE false. 2. The query is better represented by a reduced query on fragments that joins PROJ1 with ASG1 on the PNO attribute, PROJ2 with ASG2 on PNO, and PROJ2 with ASG3 on PNO, rather than the generic query that performs a full join. 3. The join graph shows the relations R1, R2, R3, and R4 and their initial statistics including relation size and attribute size and selectivity factor values.

Uploaded by

Saimo Mghase
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
366 views10 pages

Ans Assi2

1. The SQL query is simplified using idempotency rules to FALSE, so the transformed query returns SELECT ENO FROM ASG WHERE false. 2. The query is better represented by a reduced query on fragments that joins PROJ1 with ASG1 on the PNO attribute, PROJ2 with ASG2 on PNO, and PROJ2 with ASG3 on PNO, rather than the generic query that performs a full join. 3. The join graph shows the relations R1, R2, R3, and R4 and their initial statistics including relation size and attribute size and selectivity factor values.

Uploaded by

Saimo Mghase
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

Answers to assignment 2

1. (8.1) Simplify the following query, expressed in SQL, on our


example database using iempotency rules:

SELECT ENO
FROM ASG
WHERE RESP = “Analyst”
AND NOT (PNO= “P2” OR DUR = 12)
AND PNO “P2”
AND DUR = 12

Denote RESP = “Analyst” P1, PNO = “P2” P2, and DUR = 12 P3. So the
SQL statement can express as: P1  (P2P3)  P2P3.
Following idempotency rules:

P1(P2P3)P2P3

P1(P2P3) P2P3

P1 P2P3P3

P1 P2FALSE

FALSE

The SQL can be transformed as


SELECT ENO
FROM ASG
WHERE false

2 (8.7) Assume that relation PROJ and ASG are horizontally


fragmented as follows:

PROJ1 = σpno �“p2”(PROJ) ASG1 = σpno �“p2”(ASG)


PROJ2 = σpno >“p2”(PROJ) ASG2 = σ“p2” < pno �“p3”(ASG)
ASG3 = σpno >“p3”(ASG)
Transform the following query into a reduced query on
fragments, and determine whether it is better than the generic
query:
SELECT RESP, BUDET
FROM ASG, PROJ
WHERE ASG.PNO = PROJ.PNO
AND PNAME = “CAD/CAM”
The generic query can be represented by the following tree:
∏RESP,BUDGET

σPNAME =“CAD/CAM”

⋈PNO

 

PROJ1 PROJ2 ASG1 ASG2 ASG3

Because PROJ1 = σpno ≤ “p2”(PROJ)


PROJ2 = σ pno > “p2”(PROJ)
ASG1 = σpno ≤ “p2”(ASG)
ASG2 = σ“p2” < pno ≤ “p3”(ASG)
ASG3 = σpno > “p3”(ASG),
This tree can be represented as the following tree
∏RESP, BUDGET

⋈PNO

∏PNO, BUDGET ∏PNO, RESP

σPNAME = “CAD/CAM” 


ASG1 ASG2 ASG3

PROJ1 PROJ2

This tree can be reduced as the following tree


∏RESP, BUDGET ∏RESP, BUDGET


∏RESP, BUDGET

⋈PNO ⋈PNO
⋈PNO

∏PNO, BUDGET ∏PNO, RESP ∏PNO, BUDGET ∏PNO, RESP


∏PNO, BUDGET
∏PNO,
RESP
σPNAME = “CAD/CAM” ASG1 σPNAME = “CAD/CAM” ASG2
σPNAME = “CAD/CAM”
ASG2

PROJ1 PROJ2
PROJ2

3. (9.6) consider the following join graph:

Initial Statistics:
relation size
R1 1000
R2 1000
R3 2000
R4 1000
attribute size SF
R1.A 200 0.5
R2.A 100 0.1
R2.B 100 0.2
R3.B 300 0.9
R4.b 150 0.4

You might also like