Sie sind auf Seite 1von 3

8.

5 EXERCISES
8.1 Simplify the following query, expressed in SQL, on our example database
using idempotency rules:

SELECT END
FROM ASG
WHERE RESP = "Analyst"
AND NOT(PNO="P2" OR DUR=12)
AND PNO # "P2"
AND DUR=12

8.2 Give the query graph of the following query, expressed in SQL, on our
example database:

SELECT ENAME. PNAME -?'"


FROM E.'1P. ASG, PRO]
WHERE DUR > 12 t\.
AND EMF.ENO = ASG.ENO

and map it into an operator tree.


*8.3 Simplify the following query:

SELECT ENAME. PNAME


FROM EMF, ASG, PRO]
WHERE DUR > 12 . J .

AND EMF.rim = ASG'-ENO ~


rAND (TITLE = " 'Elect.'Eng.~./
-LOR ASG.PNp < "P3")
AND
ASG. PNO' = PRO]. PNO ...--
and transform it into an optimized operator tree using the restructuring

G
lgorithm. .

*8.4 ansform the operator tree of Figure 8.5 back to the tree of Figure 8.3
sing the restructuring algorithm. Describe each intermediate tree and show
which rule the transformation is based on.
.fj
\
'->

...
--,
,. 226 Query Decompositionand Data Localization. Chapter 8

**8.5 Consider the following query on our Engineering database:

SELECT ENAME,SAL .
FROM EMF,PRoJ,ASG,PAY
WHERE EMP.ENo = ASG.ENo
AND EMF.TITLE = PAY.TITLE
AND (BUDGET>200000 OR DUR>24)
AND ASG.PNo = PRoJ.PNo

Compose the selection predicate corresponding to the WHERE-clause and


transform it, using the idempotency rules, into the simplest equivalent form.
Furthermore, compose an operator tree corresponding to the query and
transform it, using relational algebra transformation rules, to a form that is
optimal with respect to total"execution time, by considering only the selec-
tivity factors of operations.

8.6 Assume that relation PROJ of the sample database is horizontally frag-
mented in

PROJ) O'PNO~"P2" (PROJ)


PROJ2 O'PNO>"P2"(PROJ)

Transform the following query into a reduced query on fragments:

SELECT BUDGET
FROM PRoJ,ASG
WHERE PRoJ.PNo = ASG.PNO
AND ASG.PNo = 'cp4"

*8.7 Assume that relation PROJ is horizontally fragmented as in Exercise 8.6,


and that relation ASG is horizontally fragmented as

ASG1 O'PNO~"P2" (ASG)


ASG2
ASG3 = 0"':2"<'PNO~"P3,,(ASG) ~
O'PNo>"p~,,(ASG)

Transform the following query into a reduced query on fragments, and de-
termine whether it is better than the generic query:

SELECT RESP, BUDGET


FROM ASG, PRoJ
WHERE ASG.PNo = PRoJ.PNo
AND PNAME= 'c CAD/CAM'."'"'--- (1,
Section 8.5. EXERCISES 227

**8.8 Assume that relation PROJ is fragmented as in Exercise 8.6. Furthermore,


relation ASG is indirectly fragm~nted as

ASG1 ASG t><PNOPROJ1


ASG2 ASG [XPNOPROJ2

and relation EMP is vertically fragmented as

EMP1 IIENo,ENAME(EMP)
EMP2 IIENo,TITLE (EMP)

Transform the following query into a reduced query on fragments:

SELECT ENAME
FROM EMP,ASG.PROJ
WHERE PROJ.PNO = ASG.PNO
AND PNAME = «Instrumentation "
AND EMP.ENO= ASG.ENO

Das könnte Ihnen auch gefallen