PROPOSICIÓN NO DE LEY
5. A CTIVIDAD P ARLAMENTARIA 1COMPARECENCIAS
5.2.2 P REGUNTAS DE R ESPUESTA O RAL EN C OMISIÓN
Given a query, if more than one variable is defined and they are depen- dent on each other based on their definitions, then the original hierarchies among their corresponding data bindings are preserved. Below we define this notion of variable dependencies.
Definition 3.1 (Variable Binding Dependency) Suppose a variablev
jin a query is defined based on a previously defined variablev
i, e.g., “for v j in v i p j”, where p
j is the relative XPath expression used for deriving the bindings of v
j from those ofv
i. We call this dependency of v
j on v
ia variable binding dependency and denote it asv i p j Bv j. v
i is referred to as the parent variable in this dependency and v
A variable dependencyv i
p j Bv
j means that the variable bound expres- sion forv
j can be evaluated only in the context when the mapping M(v
i )
Value i
)is already available indynEnv(see Rule (3) in Section 3.2.1). This is because the bindingsValue
iof v
ineed to be looked up to derive the new
mappingM 0 (v j ) Value j
). The latter is then added intodynEnv. Given a data bindingoin the binding setValue
i, the set of data objects that are rooted atoand navigated to viap
j can be identified and added in Value
j. No two data objects in Value
i have an overlapping descendant object set inValue
j.
For example, in the example queryQ1shown in Figure 3.1, variable $b is defined by the XPath expression navigating from the root to the book el- ements. Later the variable $t is defined based on $b. Then the hierarchies between the book elements and their respective children title elements are preserved by the bindings of $b and those of $t, similarly the hierarchies between the bindings of $b and those of $a are preserved. This way, the sibling title-author association derived from their common ascendant book element is also preserved. Such associations are reflected by the title and author’s last elements contained within each new entry element being con- structed correspondingly for each book element binding.
For a given queryQ, we call every direct parent-child variable binding dependency ofQ a base variable binding dependency. From the set of such base dependencies, the ancestor-descendant dependencies can be de- rived inductively by applying the rule: v
i p j Bv j and v j p k Bv k =)v i p jk Bv k. In this rule,p
jkis the path expression obtained by concatenating p
j and p
3.3. VARIABLES IN XQUERY 69 andv i p jk Bv
kdenotes a derived variable binding dependency.
Since we restrict XPath expressions in the defined XQuery fragment to be non-recursive and downwards navigations only, all the base variable dependencies form a tree structure if a single source XML document is in- volved. In this variable dependency tree, the hierarchies among the data bindings associated with the variable nodes are all preserved. In other words, the hierarchical relationships among the intermediate data bindings are implied by the base variable dependency set of a query. Hence, we may infer the subsumption of the preserved data bindings and their hierarchi- cal relationships in different queries by reasoning about the containment of their respective variable dependencies.
In the example queryQ1shown in Figure 3.1, variable $b is defined by a nested FLWR expression returning the book elements derived by navigating from the binding of $b1 via the path expression //book. Suppose we assign a default variable $r to be bound to the root element of the source document. Thus$r Q1 : B$d Q1 ,$d Q1 : B$b1 Q1 and$b1 Q1 ==book B $b Q1
. $t and $a are both defined based on $b. Hence we have$b
Q1 =titl e B $t Q1 and$b Q1 =author B $a Q1 . Q2defines its variable $b directly from the root element via the path ex- pression //book, and the other two variables $t and $a by the path expres- sions /title and /author based on $b respectively. Hence the base variable dependencies obtained fromQ2 are$r
Q2 ==book B $b Q2 ,$b Q2 =titl e B $t Q2 , and $b Q2 =author B $a Q2 . $r Q1 and$r Q2
are the same since they both are bound to the root element of the same source document.
andv i p j Bv j, v i p k Bv
kare two base variable dependencies in it. For each binding of v
i, the respective binding sets of its children variables v
jand v
kcan be determined. We hence call such variable dependencies joinable based on their common parent variable.
For example, in both queriesQ1andQ2, variables $t and $a are defined based on $b. For each binding of $b, the respective bindings of $t and $a can be determined. In this sense, the association relationship between the sibling title and author elements that are derived from the same book parent element is established.
Suppose another queryQ3defines its two variables $t Q3
and$a Q3
re- spectively from the root element of the same source document via the path expressions of //book/title and //book/author. Although $t
Q3
and $a Q3
are bound to the title and author elements, which are the same as for $t and $a defined inQ1or inQ2, the information about the sibling title-author el- ement associations grouped by their parent book elements is lost. That is, the intermediate binding results for$t
Q3
and$a Q3
are grouped document- wise, whereas those for $t and $a in Q1 or Q2 are grouped by their re- spective parent book elements. For example, by merging all the title data bindings of$t
Q2
and those of $a Q2
regardless of their different book par- ent elements, we can obtain the same data bindings as those of$t
Q3 and those of$a
Q3
respectively. This is implied by the fact that from the base dependency setf$r Q2 ==book B $b Q2 , $b Q2 =titl e B $t Q2 , $b Q2 =author B $a Q2 g, we can derivef$r Q2 ==book=titl e B $t Q2 ,$r Q2 ==book=author B $a Q2 g. Since$r Q2 is ex- actly the same as$r
Q3
3.3. VARIABLES IN XQUERY 71
the base variable dependencies defined inQ3. However, the base variable dependencies inQ2cannot be derived from those inQ3.