L15-16 (Query Decomposition) PDF
L15-16 (Query Decomposition) PDF
SELECT ENAME
FROM EMP, ASG
WHERE EMP.ENO = ASG.ENO
AND ASG.PNO = "P1"
AND DUR = 12 OR DUR = 24
Qualification in disjunctive NF is
(EMP.ENO = ASG.ENO ∧ ASG.PNO = “P1” ∧ DUR = 12) ∨
(EMP.ENO = ASG.ENO ∧ ASG.PNO = “P1” ∧ DUR = 24)
Problem is that join predicates are missing and the query should be
rejected.
SELECT TITLE
FROM EMP
WHERE (NOT (TITLE = "Programmer") AND (TITLE = "Programmer"
OR TITLE = "Elect. Eng.")
AND NOT (TITLE = "Elect. Eng.")) OR ENAME = "J. Doe”
Can be written as
SELECT TITLE
FROM EMP
WHERE ENAME = "J. Doe"
SELECT ENAME
FROM PROJ, ASG, EMP
WHERE ASG.ENO = EMP.ENO
AND ASG.PNO = PROJ.PNO
AND ENAME != "J. Doe"
AND PROJ.PNAME = "CAD/CAM" AND (DUR=12 OR DUR=24)
Localization program is
EMP= EMP1⋈eno EMP2
BITS Pilani, Hyderabad Campus
Reduction for vertical
fragmentation
• Similar to horizontal fragmentation, queries on vertical
fragments can be reduced by determining the useless
intermediate relations and removing the subtrees
that produce them.
• Projections on a vertical fragment that has no attributes
in common with the projection attributes (except the key
of the relation) can produce useless, though not empty
relations.
EMP1 = σtitle=“programmer”(EMP)
EMP2 = σtitle≠“programmer”(EMP)
• The left subtree joins two fragments, ASG1 and EMP2, whose qualifications
conflict because of predicates TITLE = “Programmer” in ASG1, and TITLE
≠“Programmer” in EMP2. Therefore the left subtree which produces an
empty relation can be removed, and the reduced query is obtained.
• Query Decomposition
• Data Localization
• Next Lecture
Query Optimization
• Questions??