• No se han encontrado resultados

DE LA COMUNIDAD DE MADRID A) MOTIVACIÓN Y ANTECEDENTES

With the presence of variable region dependencies implied by the extended VarTree, our VarTree homomorphism needs to consider two additional con- ditions which further validate each variable mapping pairhv;wiwithw= (v)established based on Definition 3.6.

Condition of Variable Region Dependency Mapping. SupposeVT1and

VT2 are the extended VarTrees ofQ1 and Q2respectively. For a parent- child variable pair u;v 2 V

vt2, if

(u) = x and (v) = w (x;w 2 V vt1)

3.7. EXTENDED MAC MAPPING PROCEDURE 105

are established based on the conditions in Definition 3.6, andx ,! w(not necessarilyxBwthough), then(v)=wis valid only ifu,!vas well.

This is because if variable x is evaluated to be an empty binding set, then even if it may not be the case forw,w’s bindings will not be returned due to x ,! w. Another fact is that since x is the mapping node for u (i.e.,(u) = x), the binding set of the former subsumes that of the latter. This implies thatu is evaluated to be an empty binding set too. Suppose u,!=v, then a non-empty binding set ofvwill be returned regardless of the empty binding set ofu. This means that(v)=wis not valid.

Below we add condition 4) into the requirements for VarTree homomor- phism (see Definition 3.6).

4). if(u),!(v), thenu,!v.

Condition of Where-Condition Mapping. For each established variable pair mapping, we also need to check its validity with the presence of where- conditions. That is, for each variablev 2 V

vt2, if it resides in a hypernode r

i 2HV

vt2which is associated with a set of where conditions denoted as C2 (C2HC vt2), then (v)2V vt1resides in a hypernode r j 2HV vt1which is associated with a condition set(C2)((C2)HC

vt1) such that 5).(C2)C2.

here means that there is mapping from the predicates and variables in (C2)to those ofC2. That is, for each semi-interval arithmetic comparison involved in(C2), there is a mapping comparison inC2which asserts a more strict condition.

3.7.3 Put All Together: Extended VarTree Homomorphism

To sum it up, we give the definition for the extended VarTree homomor- phism below.

Definition 3.11 (Extended VarTree homomorphism) Let VT1 and VT2 be the extended VarTrees ofQ1andQ2respectively. An extended VarTree homomor- phism fromVT2 toVT1, denoted VT2  VT1, if a total mapping function  from the nodes ofVT2 to those ofVT1 exists such that for all nodesuandv of VT2:

1). uis an ancestor ofvinVT2iff(u)is an ancestor of(v)inVT1; 2). 2(v)1((v));

3). ifT(v) = VAR, thenT((v))= VARorR ET; ifT(v) =R ET, then T((v))=R ET;

4). if(u),!(v), thenu,!v;

5). ifC2and(C2)are the condition sets associated respectively with two hy- pernodes r i 2 HV vt2 and r j 2 HV

vt1 and every variable node enclosed withinr

iis mapped to a variable node enclosed by r

j, then

(C2)C2.

We now give the main result of this chapter, i.e., the technique of con- tainment checking for the XQuery fragment defined in Section 3.2 which guarantees the soundness of the containment conclusion.

Theorem 3.2 (Extended VarTree Homomorphism for XQuery Containment) Given two normalizedQ1andQ2, Q2  Q1if an extended VarTree homomor-

3.7. EXTENDED MAC MAPPING PROCEDURE 107

phismVT2VT1exists withVT1andVT2being extended VarTrees as defined in Definition 3.10.

Proof. SupposeVT2VT1. This implies that the conditions 1)3) re- quired in Definition 3.6 and the two additional conditions 4)5) described in Section 3.7.2 are all satisfied. This is a contained query case, i.e.,Q2Q1, due to the reasons below. First, based on Proposition 3.2, we can derive that for each nodevinVT2,v’s binding set is subsumed by the binding set of (v). Second, since VT1 and VT2 both contain only essential variables, there is a one-to-one correspondence mapping between variables in VT1 andTT1and between variables inVT2andTT2based on Proposition 3.1. This means that the query result containment can be reduced to variable binding set containment. Third, condition 4) guarantees that if there is a loss of information during the construction ofQ1’s result from(v)’s bind- ings due to variable region dependencies, then the return ofv’s bindings inQ2’s result is also blocked. Fourth, condition 5) ensures that all the con- ditions inQ1 have mapping conditions and they are less strict than their corresponding ones. Therefore, it can be inferred that each new element constructed in the result ofQ2has a mapping element in the result ofQ1, and that each variable binding returned in the result ofQ2also has a map- ping binding in the result ofQ1. Thus we deriveQ2Q1.

Similarly, we can also prove that a containment mapping between the variables and predicates of the two monadic datalog programs P1, P2 translated from VT1 and VT2 respectively can be used for determining query containment. The basic mapping translation is introduced in Sec-

tion 3.6.3, while condition 4) is translated to the mapping ofRs, i.e., the references to other head predicates, and condition 5) is translated to the mapping ofCs, i.e., the condition-related predicates.

The Extended MAC Mapping Procedure. To incorporate conditions 4)5) into the previous MAC mapping procedure (given in Figure 3.13) and thus to realize the extended VarTree homomorphism, we modify the VarTree traversal process to take care of the additional properties of an extended VarTree. That is, for a given extended VarTree, the navigation from a hyper- node to another is via the directed hyperedge and the navigation between variable nodes within a hypernode is via the variable binding dependency edge. This corresponds to a top-down traversal of the nested FWR blocks and check for variable mappings.

Such a traversal asserts a stricter order than the previous traversal order as described in Figure 3.13. However, it does not conflict with the previous one due to Proposition 3.3.

In addition, we add the checking steps for conditions 4)5) to validate the established mapping. The main idea exploited to achieve this is to aggregate the mapping nodes inVT1for the variables residing in each hy- pernode ofVT2 and then check if more variable region dependencies or more strict conditions can be induced from this aggregated set than from the original variable set.

3.7. EXTENDED MAC MAPPING PROCEDURE 109

ALGORITHM Extended VarTree MAC Mapping INPUT: Extended VarTreesVT1andVT2.

OUTPUT: Variable mapping pair setMS =fhv;(v)ig. TraverseVT2in preorder

Foreachencountered hypernoder i 2HV vt2 Do InitializeV ri =fvjvresides inr i g,S ri =;,R j =;. Foreachvariable nodevenclosed inr

i Do

Check ifparent(v)has a mapping, continue only if one exists;

Search forv’s mapping nodewwithin the scope of the subtree rooted at (parent(v))such thatwsatisfies:

1).2(v)1(w)

2). ifT(v)=VAR, thenT(w)=VARorR ET; ifT(v)=R ET, thenT(w)=R ET.

Ifsuch awexists Then

establish a mapping pairhv;wi; Supposewresides in a hypernoder

j 2HV vt1, then S ri +=fuju2r j g,R j +=fr j g; End If End Foreach IfV ri =S ri Then

hv;wiis valid and hence added into the mapping setMS; End If

End Foreach

Ifthere exists a total mapping from variables inVT2to those inVT1 Then outputVT2VT1and the mapping setMS;

End If

Chapter 4

XQuery Rewriting

4.1

Issues in XQuery Rewriting

If a new XQueryQ2is determined to be contained in or overlap with a view XQueryQ1, we then need to formulate the probe query ofQ2with respect to the result view structure ofQ1 so that the (total or partial) answer to Q2can be directly retrieved from the cached view result ofQ1. Intuitively, this would involve rewriting the bound expressions ofQ2’s variables with respect to the view structure ofQ1.