You are on page 1of 2

Assume that relation PROJ of the text’s sample database is horizontally fragmented

as follows:
PROJ1 = σPNO ≤ ’P2’(PROJ)
PROJ2 = σPNO > ’P2’(PROJ)
Transform the following query into a reduced query on fragments:
select ENO, PNAME
from PROJ, ASG
where PROJ.PNO = ASG.PNO
and PNO = ‘P4’

Solution
The general query on fragments is:

SELECT ENO, PNAME


FROM PROJ1, ASG
WHERE PROJ1.PNO = ASG.PNO
AND ASG.PNO = ''P4''

UNION

SELECT ENO, PNAME


FROM PROJ2, ASG
WHERE PROJ2.PNO = ASG.PNO
AND ASG.PNO = ''P4''

Tree for the fragmented query above

 ENO, PNAME

PNO=”P4”

 PNO  PNO

PROJ1 ASG PROJ2 ASG

The sub-trees that produce an empty relation can be removed. This process is called the
query reduction. In this case, the PROJ1 doesn’t have any records with PNO=”P4” based
on the fragmentation rule. Hence, the join of PROJ1 and ASG would return an empty
set. Therefore, we eliminate the left subtree.
Based on the fragmentation rule, PROJ2 may have records with PNO=”P4”. In that case,
the join with ASG would not return an empty set. Therefore, that subtree remains.
Because we have only one subtree left, the union operation is also eliminated. The
reduced subtree is:

 ENO, PNAME

PNO=”P4”

 PNO

PROJ2 ASG

The corresponding query is:


SELECT ENO, PNAME
FROM PROJ2, ASG
WHERE PROJ2.PNO = ASG.PNO
AND ASG.PNO = ''P4''

The Budget attribute is in the project relation, and the query doesn’t select any attributes
from the ASG relation. We have a useless join that needs to be eliminated.

The resulting query tree is:

 ENO, PNAME

PNO=”P4”

PROJ2

The corresponding query is:


SELECT ENO, PNAME
FROM PROJ2
WHERE PNO=”P4”

You might also like