Abstract
The article introduces a simple framework for the specification of constraints for XML documents in which constraints are specified by (1) a mapping that extracts a relation from every XML document and (2) a relational constraint on the resulting relation. The mapping has to be generic with respect to the actual data values and the relational constraints can be of any kind. Besides giving a general undecidability result for firstorder definable mappings and a general decidability result for MSO definable mappings for restricted functional dependencies, the article studies the complexity of the implication problem for XML constraints that are specified by tree pattern queries and functional dependencies. Furthermore, it highlights how other specification languages for XML constraints can be formulated in the framework.
Similar content being viewed by others
Notes
The exact framework of our reasoning algorithms will be introduced later.
As usual, we could allow a set of attributes instead of the single attribute B but such FDs can always be rewritten as a set of FDs with singleton attributes.
This includes noninjective mappings.
The precise kinds of schemas that we consider will be defined later on.
The name stems from the fact that these FDs very closely correspond to XML key constraints.
We note that Kot and White define the mapping of a tree pattern using unfolding of nested relations. The definition is equivalent to our definition using embeddings.
Duplicate free tree patterns have been considered in [15]
This constraint ensures that all embeddings are maximal, as required in the definition of tree pattern based mappings.
The restriction π_{1}(B) ≠ ⊥ is not strictly necessary, but it will simplify some proofs. Note that at least one of π_{1}(B) and π_{2}(B) has to be different from ⊥ in any case and we can exchange π_{1} and π_{2}.
We will not introduce join and inclusion dependencies formally.
We note without proof, that one can achieve that the resulting tree is independent of the order in which violated dependencies are corrected, by introducing a total order on the data values and always replace the larger data value with the smaller one. Analogously a total order on the nodes of the tree needs to be introduced.
We choose a different label because the meanings of ∗ and # are slightly different. The label ∗ is a true wildcard that can match any symbol. The label # is chosen for a node, which has some unique label, but we do not know yet which label this should be. The label ∗ only occurs in patterns while the label # only occurs in trees.
We use the index τ to distinguish references to components of the targetdependency from references to dependencies fromΣ.
That is ν maps χ_{2}(B) and its root path to χ_{1}(B) and its root path and is the identity on all other nodes.
And we will see soon that there is more than one initial tree.
In cases (c) and (d), actually [t]_{S}is the actual counterexample.
In other words: all paths missing in U consist of at least three edges.
Since the label of a path edge below a node u indicates the label of the child of u on that path, the extension does not need to add another child of u with that label.
In the final algorithm, U has to satisfy some additional conditions.
Stated otherwise, a cluster is a connected component of p after removing all descendant edges.
We note that an induced witness pair is not necessarily a witness pair but rather a subwitness pair.
We note that this is a key constraint, but also the only kind of FD with a set of two attributes in Σ.
We note that it does not matter, whether the set of row numbers is disjoint from the set of column numbers as they never interact with each other.
We note that this constraint connects the last tile of a row with the second of the next row and the last tile but one of one row with the first tile of the next row.
Here we use the assumption that valid tilings have width ≥ 4.
We assume a more general notion of a witness pair here. It is clear that Lemma 6.4 canbe generalized for witness pairs, where the mapping is specified by an FO formula.
Remember, that we assume w.l.o.g. that π_{1}(B) ≠ ⊥.
We use this algorithm to simplify the correctnessproof. It is possible to directly compute the correct node of p such that one invocation of removenull suffices.
If removenull would not have been called, the resulting tree would have been t_{4} implying that τ already follows from σ_{2}.
References
Arenas, M., Fan, W., Libkin, L.: On the complexity of verifying consistency of XML specifications. Siam Journal on Computing 38(3), 841–880 (2008)
Arenas, M., Barcelo, P., Libkin, L., Murlak, F.: Relational and xml data exchange. Synthesis Lectures on Data Management 2(1), 1–112 (2010)
Arenas, M., Libkin, L.: A normal form for XML documents. ACM Trans. Database Syst. 29, 195–232 (2004)
Atzeni, P, Morfuni, N.M.: Functional dependencies and constraints on null values in database relations. Inf. Control. 70(1), 1–31 (1986)
Buneman, P., Davidson, S.B., Fan, W., Hara, C.S., Tan, W.C.: Reasoning about keys for XML. Inf. Syst. 28(8), 1037–1063 (2003)
Buneman, P., Davidson, S., Fan, W., Hara, C., Tan, W.C.: Keys for XML. Comput. Netw. 39(5), 473–487 (2002)
Doner, J.: Tree acceptors and some of their applications. J. Comput. Syst. Sci. 4(5), 406–451 (1970)
Gao, S., SperbergMcQueen, C.M., Thompson, H., Mendelsohn, N., Beech, D., Maloney, M.: W3C XML Schema definition language (XSD) 1.1 Part 1: Structures http://www.w3.org/TR/2012/RECxmlschema11120120405/ (2012)
Hartmann, S., Link, S.: More functional dependencies for XML. In: Kalinichenko, L., Manthey, R., Thalheim, B., Wloka, U. (eds.) Advances in Databases and Information Systems, volume 2798 of LNCS, pp. 355–369. Springer, Berlin/Heidelberg (2003)
Hartmann, S., Link, S., Schewe, K.D.: Functional dependencies over XML documents with DTDs. Acta Cybernetica 17(1), 153–171 (2005)
Hartmann, S., Link, S., Trinh, T.: Solving the implication problem for XML functional dependencies with properties. In: WoLLIC, pp. 161–175 (2010)
Kot, L., White, W.M.: Characterization of the interaction of XML functional dependencies with DTDs. In: International Conference Database Theory (ICDT), pp. 119–133 (2007)
Lee, M., Ling, T., Low, W.: Designing functional dependencies for XML. In: International Conference on Extending Database Technology (EDBT), pp. 145–158 (2002)
Martens, W., Neven, F., Schwentick, T., Bex, G.J.: Expressiveness and complexity of XML schema. ACM Trans. Database Syst. 31(3), 770–813 (2006)
Miklau, G., Suciu, D.: Containment and equivalence for a fragment of XPath. J. ACM 51(1), 2–45 (2004)
Stockmeyer, L.: The complexity of decision problems in automata and logic, 1974. Ph.D. Thesis, MIT (1974)
Thatcher, J.W., Wright, J.B.: Generalized finite automata theory with an application to a decision problem of secondorder logic. Mathematical Systems Theory 2(1), 57–81 (1968)
van Emde Boas, P.: The convenience of tilings. In: Sorbi, A. (ed.) Complexity, Logic and Recursion Theory, volume 187 of Lecture Notes in Pure and Applied Mathematics, pp. 331–363. Marcel Dekker Inc. (1997)
Vincent, M.W., Liu, J., Liu, C.: Strong functional dependencies and their application to normal forms in XML. ACM Trans. Database Syst. 29(3), 445–462 (2004)
Acknowledgements
We acknowledge the financial support of the Future and Emerging Technologies (FET) program within the Seventh Framework Programme for Research of the European Commission, under the FETOpen grant agreement FOX, number FP7ICT233599.
The first author has been supported by grant number MA 4938/21 of the Deutsche Forschungsgemeinschaft (Emmy Noether Nachwuchsgruppe).
We would like to thank Gaetano Geck for fruitful discussions and valuable feedback.
Author information
Authors and Affiliations
Corresponding author
Appendix: Chasing with Fictitious Functional Dependencies
Appendix: Chasing with Fictitious Functional Dependencies
Now, we extend the chase algorithm, such that it works in the presence of fictitious functional dependencies. To extend the chase algorithm, we have to deal with two separate issues. First, the dependencies in Σ can be fictitious. In this case, we have the problem that π_{2}(B) might be null in Line 4 of Algorithm 1.^{Footnote 27} We note that Algorithm 2 cannot handle null values. On the other hand, the target dependency τ can be fictitious.
To address both issues, we change the definition of the initial tree and extend Algorithm 1, as can be seen in Algorithm 4. The red parts (Lines 6–11 and additional function parameters) are added to deal with a fictitious target dependency and the blue part (Lines 4–5) is added to deal with fictitious dependencies in Σ. We note that removing the red and blue parts in Algorithm 4 gives exactly Algorithm 1. Algorithm 5 is identical to Algorithm 3, except that it computes a witness pair for t_{τ} ⊮ τ and provides the additional parameters to the chase function.
We first describe how we deal with fictitious dependencies in Σ, especially with the case that π_{2}(B) is null in Line 4. We address this problem, by adding a function that removes null values from embeddings by adding nodes to the tree, such that the null value is replaced by a node or data value. We therefore define the function removenull that takes as input a tree t, a pattern p, a partial embedding π of p in t and a node x of p such that π(x) = ⊥.
The function removenull computes and returns a tree t^{′} and a (partial) embedding π^{′} of p in t^{′} as follows. Let y be the lowest ancestor of x with π(y) ≠ ⊥, z be the child of y on the path [y, z] and v be π(y). The tree t^{′} is derived from t by adding a copy of the path [z, x] to t below π(y), where each added node gets a fresh node identifier from \({\mathcal {V}}\) and a fresh data value from \({\mathcal {V}}\) and wildcard symbols are replaced by #. The embedding π^{′} is derived from π by embedding the path [z, x] to the newly inserted path in t^{′}.
The intuitive idea behind this function is that π_{1}(B) must be identified with π_{2}(B) to satisfy σ. Therefore either π_{1}(B) must become ⊥ (meaning π_{2}(y) has to be removed from the tree) or π_{2}(B) must become equal to π_{1}(B), which especially means that it must become different to ⊥. We just note that removing nodes from the tree (contrary to merging them) is a bad idea, because the initial tree is an—in some sense—minimal counterexample. Therefore we add nodes to remove the nulls. For correctness we refer to the formal proof given below.
Note that in the case that B = y, where y is a node, the chase will merge the newly added node with π_{1}(B) afterwards, i.e., the effect of removenull followed by the merge is equivalent of merging π_{1}(y) with π_{2}(y), where y is defined as the lowest ancestor of B, which is not mapped to ⊥.
We now describe how to deal with the case, where the target dependency τ is fictitious. To understand the underlying problem, we give an abstract example.
Example A.1
We consider the mapping induced by the patternp = /a〈x_{a}〉/b〈x_{b}〉/c〈x_{c}〉 and the dependencies \(\tau =(p,{x_{a} \overset {\emptyset }{\to } x_{c}})\), \(\sigma _{1}=(p,{x_{a} \overset {x_{c}}{\rightarrow } x_{c}})\), and \(\sigma _{2}=(p,{x_{a} \overset {\emptyset }{\to } x_{b}})\). We note that σ_{1} is not strictly fictitious, as it only applies to embeddings where no node is mapped to⊥. It can be easily seen that σ_{1} ⊮ τ and σ_{2} ⊮ τ, as the tree t_{1} in Fig. 5 is a counterexample to σ_{1} ⊧ τ and t_{3}is a counterexample to σ_{2} ⊧ τ. Later, we will see that {σ_{1}, σ_{2}} ⊧ τ.
Starting with Σ = {σ_{1}} and τ, Algorithm 3 will incorrectly report that σ_{1} ⊧ τ, as it starts with the initial tree t_{2}, merges nodes v_{3} and v_{5} to satisfy σ_{1} and recursively merges nodes v_{2} and v_{4} to restore the tree structure. The resulting tree t_{4} satisfies σ_{1} and τ and therefore Algorithm 3 erroneously reports that σ_{1} ⊧ τ.
The intuitive reason for the incorrect behavior is that Algorithm 3 does not consider trees, where the witnesspair for τ involves null values, i.e., τ is treated as a nonfictitious dependency.
It is easy to see that starting with t_{1} as initial tree would allow Algorithm 1 to correctly decide that σ_{1} ⊮ τ. However, simply adapting the initial tree will not work, as can be seen by the dependency σ_{2}. Starting with initial tree t_{1} and Σ = {σ_{2}}, Algorithm 1 will merge nodes v_{2} and v_{4} to satisfy σ_{2}. The resulting tree t_{4} again satisfies τ, which leads to the (again incorrect) result σ_{2} ⊧ τ. The intuitive reason now is, that with t_{1} as initial tree, Algorithm 1 no longer considers trees where the witnesspair for τ does not use null values.
A possible solution would be to run Algorithm 1 starting from both initial trees and output “yes”, if and only if both runs output “yes”. We note without proof that this solution could be generalized to arbitrary FFDs resulting in at most linearly many initial trees in the depth of p, each with a different number of nodes from p mapped to null in the witnesspair. Instead of this approach, we take a more elegant solution in using an initial tree, where the witnesspair has as many as possible null values and extend Algorithm 1 such that it adds more nodes to the tree when it becomes apparent that the chosen initial tree will result in a final tree satisfying τ.
Therefore, we define the initial tree of a fictitious functional dependency \(\tau =(p,{Y \overset {Z}{\to } B})\) as follows: Let t_{1} and t_{2} be copies of p, where t_{1} only contains the nodes referenced in Y, Z and B together with their ancestors and t_{2} contains only the nodes referenced by Y and Z together with their ancestors. Let again π_{1} and π_{2} be the canonical embeddings of p in t_{1} and t_{2}, respectively. As before, t_{1} and t_{2} contain node ids from \(\mathcal {V}\) instead of variables from X, all data values in t_{1} and t_{2} are distinct and wildcards ∗ are replaced by #. The tree t_{τ} again results by merging the roots of t_{1} and t_{2} and all pairs (π_{1}(z), π_{2}(z)), for which z occurs as a node term in Y and it identifies all pairs of data values (π_{1}(z).@, π_{2}(z).@), for which z.@ is a data term in Y. By applying the node merges the embeddings π_{1} and π_{2} yield two embeddings \({\pi }_{1}^{\prime }\) and \({\pi }_{2}^{\prime }\) such that \(({\pi }_{1}^{\prime }, {\pi }_{2}^{\prime })\) is a witness pair for t_{τ} and τ.
Furthermore, we add the red parts to Algorithm 4, which take care of adding additional nodes to the tree when necessary, i.e., when a merge occurs that would result in ρ_{2} not being a maximal embedding. In this case x (as computed in Line 9) cannot be mapped to ⊥ any more and the function removenull is invoked to add a new node for mapping x. We loop using the goto statement in Line 12 as it might be necessary to remove further nulls.^{Footnote 28}
Coming back to Example A.1, we want to give the chase sequence for Σ = {σ_{1}, σ_{2}} and τ. Algorithm 5 starts with computing the initial tree t_{1} (in Fig. 5). As σ_{2} is not satisfied, the nodes v_{2} and v_{4} need to be merged. Prior to this merge, removenull is called in Line 11, resulting in tree t_{2}. The chase continues with merging v_{2} and v_{4} resulting in tree t_{3}.^{Footnote 29} Now σ_{1} is violated resulting in a merge of v_{3} and v_{5} and the final tree t_{4}. As t_{4} ⊧ τ, Algorithm 5 reports that {σ_{1}, σ_{2}}⊧τ. As we will see in Proposition A.2, this result is correct.
Proposition A.2
For every instance I = (Σ, τ) of XCImp (TP[/, ∗],FFD), Algorithm 5 terminates and answers “Yes” if and only if Σ ⊧ τ.
Proof
The proof follows a very similar outline to the proof of Proposition 7.2. The basic difference is, that we will consider calls to removenull in lines 5 and 11 as separate merge steps in our induction.
Let I = (Σ, τ) be an instance of XCImp(TP[/, ∗], FFD) with \(\tau =(p_{\tau },{Y_{\tau } \overset {Z_{\tau }}{\longrightarrow } B_{\tau }})\). Clearly, if Algorithm 5 terminates and yields a tree t, no constraint from Σ is violated in t. Thus, if the output of Algorithm 5 is “No” (and thus t ⊮ τ), t is a counterexample for Σ ⊧ τ and thus, the answer “No” is always correct. The proof that “Yes”answers are also correct again uses tree homomorphisms as defined in the proof of Proposition 7.2.
Let t_{i} be the tree after i chase steps where a chase step is either a call to removenull or a call to merge in Algorithm 4. This differs to the proof of Proposition 7.2, where only calls to merge were considered chase steps, as there where no calls to removenull.
Claim A.3 is identical to Claim 7.3, except that it holds for fictitious dependencies and uses the updated definition of a chase step.
Claim A.3
If there is a counterexample treet^{′} for Σ ⊧ τ with witness pair \((\rho ^{1}_{t^{\prime }},\rho ^{2}_{t^{\prime }})\) for τ and t^{′}, then the tree chase on input (Σ, τ) does not fail and for every chase step i it holds that

(i)
there exist a tree homomorphism \(t_{i} \preceq _{\theta _{i}} t^{\prime }\) ;

(ii)
there exist a witness pair \(({\rho }_{i}^{1},{\rho }_{i}^{2})\) for t_{i} ⊮ τ; and

(iii)
\(\theta _{i}({\rho }_{i}^{j}(x))=\rho _{t^{\prime }}^{j}(x)\) for j ∈ {1, 2} and all terms x of p_{τ} with \({\rho }_{i}^{j}(x)\neq \bot \).
Again, the claim immediately yields the correctness of the algorithm.
The proof of Claim A.3 is by induction on the number of chase steps. We distinguish 3 cases for the induction step depending on the type of the chase step: calls to removenull in Line 5, calls to removenull in Line 11 and calls to merge (in Line 15). We note that we can show these cases in any order.
We want to remember that we can safely assume that for each witness pair (π_{1}, π_{2}) considered in this proof it holds that π_{1} is a full embedding and the only nodes mapped to ⊥ in π_{2} are on the path from the root to B, where B is the node or data term on the righthand side of the corresponding dependency.
The induction base for t_{0} = τ can be shown exactly as in the proof of Proposition 7.2. The same holds true for the induction step in the case of calls to merge. It should be noted that in calls to merge, ρ_{2} always is a full embedding. This is ensured by the call to removenull in Line 5 that precedes the call to merge in Algorithm 4. It remains to show the induction step in the case of calls to removenull.
We first show the case, where removenull is called in Line 11 of Algorithm 4. Let v be the node added in removenull and x_{τ} be the corresponding term in the pattern p_{τ}. We define 𝜃_{i+ 1} to map v to \({\rho }_{t^{\prime }}^{2} (x_{\tau })\) and to be equal to 𝜃_{i} on all other nodes. By definition of embeddings, \({\rho }_{t^{\prime }}(x_{\tau })\) has to be ⊥ or a child of \(\rho _{t^{\prime }} (\text {parent}(x_{\tau }))=\theta _{i}({\rho }_{i}^{2}(\text {parent}(x_{\tau })))\). However, \(\rho _{t^{\prime }}(x_{\tau })\) cannot be ⊥, as we can conclude from (7.1) from Claim 7.3 that \(\theta _{i}({\rho }_{i}^{1}(\text {parent}(x_{\tau }))) = \theta _{i}({\rho }_{i}^{2} (\text {parent}(x_{\tau })))\). Observe that B is a node term and \({\rho }_{i}^{1}(\text {parent}(x_{\tau }))\) and \({\rho }_{i}^{2}(\text {parent}(x_{\tau }))\) are ancestors (in the same level of the tree) of \({\chi _{i}^{1}}(B)\) and \({{\chi }_{i}^{2}}(B)\). This shows that 𝜃_{i+ 1} is a valid tree homomorphism (and therefore (i) is satisfied). We define \({\rho }_{i + 1}^{1} = {\rho }_{i}^{1}\) and \({\rho }_{i + 1}^{2}\) to map x_{τ} to v and to be equal to \({\rho }_{i}^{2}\) on all other variables. It is straightforward to show that \(({\rho }_{i + 1}^{1},{\rho }_{i + 1}^{2})\) is a witness pair for t_{i+ 1} ⊮ τ, satisfying (ii). Especially \({\rho }_{i + 1}^{2}\) is a maximal partial embedding as \({\rho }_{i}^{2}\) is a maximal partial embedding and all nodes that are mapped to ⊥ in \({\rho }_{i + 1}^{2}\) are below x_{τ}, which is mapped to a leaf of the tree. From the definition of 𝜃_{i+ 1} and \(({\rho }_{i + 1}^{1},{\rho }_{i + 1}^{2})\), it follows that (iii) still holds, as the only node added to the image of \(({\rho }_{i + 1}^{1},{\rho }_{i + 1}^{2})\) is mapped accordingly in 𝜃_{i+ 1}.
At last we discuss the case where removenull is called in Line 5 of Algorithm 4. Let [v, w] be the path added to t in removenull and [x, y] be the corresponding path in the pattern p. Let y_{τ} be a variable in p_{τ} with the same ancestor string as y. Such a variable exists, as χ_{1}(y) is in the image of \({\rho }_{i}^{1}\). We define x_{τ}, such that \([x_{\tau },y_{\tau }]\) has the same length and labels as [x, y]. Again, we can conclude from (7.1) that \(\rho _{t^{\prime }}(y_{\tau })\) cannot be ⊥, as \(\rho _{t^{\prime }}^{2}(\text {parent}(x_{\tau }))=\theta _{i}({\chi _{i}^{2}}(\text {parent}(x)))\). We define 𝜃_{i+ 1} such that it is equal to 𝜃_{i} for all nodes of t_{i} and that it maps the nodes [v, w] to \([\rho _{t^{\prime }}^{2}(x_{\tau }),\rho _{t^{\prime }}^{2}(y_{\tau })]\). Similarly to the last case, it is easy to verify that 𝜃_{i+ 1} is a valid tree homomorphism and therefore we can conclude (i). We define \({\rho }_{i + 1}^{1}={\rho }_{i}^{1}\) and \({\rho }_{i + 1}^{2}\) to map the path [x, y] to the path [v, w] and to be equal to \({\rho }_{i}^{2}\) on all other nodes. Again, it is straightforward to show that \(({\rho }_{i + 1}^{1},{\rho }_{i + 1}^{2})\) is a witness pair (showing (ii)) and that 𝜃_{i+ 1} is defined in a way, such that (iii) holds. □
Using Proposition A.2, the results in Theorem 7.9 can be shown in the same way, as we have shown the results in Corollary 7.4, Propositions 7.7 and 7.8. In particular, the extension of the chase in the presence of sDTDs, which we have shown to work in Proposition 7.5 does not interfere with the addition of null values.
Rights and permissions
About this article
Cite this article
Niewerth, M., Schwentick, T. Reasoning About XML Constraints Based on XMLtoRelational Mappings. Theory Comput Syst 62, 1826–1879 (2018). https://doi.org/10.1007/s0022401898465
Published:
Issue Date:
DOI: https://doi.org/10.1007/s0022401898465