Skip to main content
Log in

Reasoning About XML Constraints Based on XML-to-Relational Mappings

  • Published:
Theory of Computing Systems Aims and scope Submit manuscript


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 first-order 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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Subscribe and save

Springer+ Basic
EUR 32.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or Ebook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4

Similar content being viewed by others


  1. The exact framework of our reasoning algorithms will be introduced later.

  2. 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.

  3. This includes non-injective mappings.

  4. The precise kinds of schemas that we consider will be defined later on.

  5. The name stems from the fact that these FDs very closely correspond to XML key constraints.

  6. 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.

  7. Duplicate free tree patterns have been considered in [15]

  8. This constraint ensures that all embeddings are maximal, as required in the definition of tree pattern based mappings.

  9. 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.

  10. We will not introduce join and inclusion dependencies formally.

  11. 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.

  12. 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.

  13. We use the index τ to distinguish references to components of the targetdependency from references to dependencies fromΣ.

  14. That is ν maps χ2(B) and its root path to χ1(B) and its root path and is the identity on all other nodes.

  15. And we will see soon that there is more than one initial tree.

  16. In cases (c) and (d), actually [t]Sis the actual counter-example.

  17. In other words: all paths missing in U consist of at least three edges.

  18. 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.

  19. In the final algorithm, U has to satisfy some additional conditions.

  20. Stated otherwise, a cluster is a connected component of p after removing all descendant edges.

  21. We note that an induced witness pair is not necessarily a witness pair but rather a sub-witness pair.

  22. We note that this is a key constraint, but also the only kind of FD with a set of two attributes in Σ.

  23. 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.

  24. 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.

  25. Here we use the assumption that valid tilings have width ≥ 4.

  26. 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.

  27. Remember, that we assume w.l.o.g. that π1(B) ≠ ⊥.

  28. We use this algorithm to simplify the correctness-proof. It is possible to directly compute the correct node of p such that one invocation of remove-null suffices.

  29. If remove-null would not have been called, the resulting tree would have been t4 implying that τ already follows from σ2.


  1. Arenas, M., Fan, W., Libkin, L.: On the complexity of verifying consistency of XML specifications. Siam Journal on Computing 38(3), 841–880 (2008)

    Article  MathSciNet  MATH  Google Scholar 

  2. Arenas, M., Barcelo, P., Libkin, L., Murlak, F.: Relational and xml data exchange. Synthesis Lectures on Data Management 2(1), 1–112 (2010)

    Article  MATH  Google Scholar 

  3. Arenas, M., Libkin, L.: A normal form for XML documents. ACM Trans. Database Syst. 29, 195–232 (2004)

    Article  Google Scholar 

  4. Atzeni, P, Morfuni, N.M.: Functional dependencies and constraints on null values in database relations. Inf. Control. 70(1), 1–31 (1986)

    Article  MathSciNet  MATH  Google Scholar 

  5. 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)

    Article  MATH  Google Scholar 

  6. Buneman, P., Davidson, S., Fan, W., Hara, C., Tan, W.-C.: Keys for XML. Comput. Netw. 39(5), 473–487 (2002)

    Article  MATH  Google Scholar 

  7. Doner, J.: Tree acceptors and some of their applications. J. Comput. Syst. Sci. 4(5), 406–451 (1970)

    Article  MathSciNet  MATH  Google Scholar 

  8. Gao, S., Sperberg-McQueen, C.M., Thompson, H., Mendelsohn, N., Beech, D., Maloney, M.: W3C XML Schema definition language (XSD) 1.1 Part 1: Structures (2012)

  9. 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)

  10. Hartmann, S., Link, S., Schewe, K.-D.: Functional dependencies over XML documents with DTDs. Acta Cybernetica 17(1), 153–171 (2005)

    MathSciNet  MATH  Google Scholar 

  11. Hartmann, S., Link, S., Trinh, T.: Solving the implication problem for XML functional dependencies with properties. In: WoLLIC, pp. 161–175 (2010)

  12. 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)

  13. Lee, M., Ling, T., Low, W.: Designing functional dependencies for XML. In: International Conference on Extending Database Technology (EDBT), pp. 145–158 (2002)

  14. Martens, W., Neven, F., Schwentick, T., Bex, G.J.: Expressiveness and complexity of XML schema. ACM Trans. Database Syst. 31(3), 770–813 (2006)

    Article  Google Scholar 

  15. Miklau, G., Suciu, D.: Containment and equivalence for a fragment of XPath. J. ACM 51(1), 2–45 (2004)

    Article  MathSciNet  MATH  Google Scholar 

  16. Stockmeyer, L.: The complexity of decision problems in automata and logic, 1974. Ph.D. Thesis, MIT (1974)

  17. Thatcher, J.W., Wright, J.B.: Generalized finite automata theory with an application to a decision problem of second-order logic. Mathematical Systems Theory 2(1), 57–81 (1968)

    Article  MathSciNet  MATH  Google Scholar 

  18. 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)

  19. 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)

    Article  Google Scholar 

Download references


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 FET-Open grant agreement FOX, number FP7-ICT-233599.

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

Correspondence to Matthias Niewerth.

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.

figure f
figure g

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 remove-null 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 remove-null 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 remove-null 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 = /axa〉/bxb〉/cxc〉 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 t1 in Fig. 5 is a counter-example to σ1τ and t3is a counter-example to σ2τ. Later, we will see that {σ1, σ2} ⊧ τ.

Fig. 5
figure 5

Example run of the chase algorithm for fictitious dependencies

Starting with Σ = {σ1} and τ, Algorithm 3 will incorrectly report that σ1τ, as it starts with the initial tree t2, merges nodes v3 and v5 to satisfy σ1 and recursively merges nodes v2 and v4 to restore the tree structure. The resulting tree t4 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 witness-pair for τ involves null values, i.e., τ is treated as a non-fictitious dependency.

It is easy to see that starting with t1 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 t1 and Σ = {σ2}, Algorithm 1 will merge nodes v2 and v4 to satisfy σ2. The resulting tree t4 again satisfies τ, which leads to the (again incorrect) result σ2τ. The intuitive reason now is, that with t1 as initial tree, Algorithm 1 no longer considers trees where the witness-pair 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 witness-pair. Instead of this approach, we take a more elegant solution in using an initial tree, where the witness-pair 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 t1 and t2 be copies of p, where t1 only contains the nodes referenced in Y, Z and B together with their ancestors and t2 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 t1 and t2, respectively. As before, t1 and t2 contain node ids from \(\mathcal {V}\) instead of variables from X, all data values in t1 and t2 are distinct and wildcards ∗ are replaced by #. The tree tτ again results by merging the roots of t1 and t2 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 remove-null 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 t1 (in Fig. 5). As σ2 is not satisfied, the nodes v2 and v4 need to be merged. Prior to this merge, remove-null is called in Line 11, resulting in tree t2. The chase continues with merging v2 and v4 resulting in tree t3.Footnote 29 Now σ1 is violated resulting in a merge of v3 and v5 and the final tree t4. As t4τ, 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 XC-Imp (TP[/, ∗],FFD), Algorithm 5 terminates and answers “Yes” if and only if Σ ⊧ τ.


The proof follows a very similar outline to the proof of Proposition 7.2. The basic difference is, that we will consider calls to remove-null in lines 5 and 11 as separate merge steps in our induction.

Let I = (Σ, τ) be an instance of XC-Imp(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 counter-example 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 ti be the tree after i chase steps where a chase step is either a call to remove-null 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 remove-null.

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 counter-example 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

  1. (i)

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

  2. (ii)

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

  3. (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 remove-null in Line 5, calls to remove-null 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 right-hand side of the corresponding dependency.

The induction base for t0 = τ 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 remove-null 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 remove-null.

We first show the case, where remove-null is called in Line 11 of Algorithm 4. Let v be the node added in remove-null 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 ti+ 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 remove-null is called in Line 5 of Algorithm 4. Let [v, w] be the path added to t in remove-null 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 ti 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

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Niewerth, M., Schwentick, T. Reasoning About XML Constraints Based on XML-to-Relational Mappings. Theory Comput Syst 62, 1826–1879 (2018).

Download citation

  • Published:

  • Issue Date:

  • DOI: