1. In Q(P, T), an entry q
ij
is 1 if the subtree rooted
at j in T includes the subtree rooted at i in P.
Otherwise, it is 0.
2. In S(P, T), each entry s
ij
is defined as follows.
Let i
1
, i
2
, …, i
k
be the child nodes of i. s
ij
is a
hypergraph H
i
= {E
1
, …, E
l
}over {i
1
, i
2
, …, i
k
}
such that T[j], the subtree rooted at j, includes
each E
g
(g = 1, …, l}, that is, for each E
g
, the
subtree rooted at j includes all the subtrees
rooted at the nodes in E
g
. But T[j] cannot
include E
i
∪ E
j
for any i, j ∈{1, …, l }.
Algorithm unordered-embedding(T, P)
Input: tree T (with nodes 1, ..., n) and tree P (with nodes 1,
..., m)
Output: Q(P, T), which shows the tree embedding.
begin
1. for v := 1, ..., n do
2. {for u := 1, ..., m do
3. {if q
uv
:= 0 then
4. {let v
1
, …, v
h
be the child nodes of v;
5. H := × … × ;
1
uv
s
2
uv
s
h
uv
s
6. let u
1
, …, u
k
be the child nodes of u;
7. if {u
1
, …, u
k
} ∈ H then set q
uv
to 1;
8. else s
uv
:= H;
9. }
10. }
11. let u
1
, …, u
l
be nodes covered by v;
12. for each ancestor v’ of v, := 1 for i = 1, …, l;
'vu
i
q
13. construct hypergraph H
= {{u
1
}, …, {u
l
}};
14. for u := 1, ..., m do
15. {let A be the set of u’s child nodes;
16. s
uv
:= H
A
;
17. }
20. }
End
The execution of line 5 will dominate the running
time of the algorithm. Let k be the largest out-degree
of any node in P. Then, the size of each s
uv
is
bounded by ≤ 2
⎣⎦
⎜
⎜
⎝
⎛
⎟
⎟
⎠
⎞
2/
k
k
k
. Especially, the size of
any product hypergraph of the form s
uv
× s
uv’
is
bounded by 2
k
(and so is s
uv
× s
uv’
× s
uv’‘
, …, and so
on.) So the time complexity of the algorithm is on
the order of O(|T|⋅|P|⋅2
2k
).
4 CONCLUSION
In this paper, a new strategy for evaluating XPath
queries is discussed. The main idea of the strategy is
to handle an XPath query as tree embedding
problem. Two strategies are proposed. One is or-
dered tree embedding based, and the other is
unordered tree embedding based. For the ordered
tree embedding problem, our algorithm needs only
O(|T|⋅|P|) time and O(|T|⋅|P|) space, where |T| and |P|
stands for the numbers of the nodes in the target tree
T and the pattern tree P, respectively. For the
unordered-tree embedding, we give an algorithm
that needs O(|T|⋅|P|⋅2
2k
) time, where k is the largest
out-degree of any node in P.
REFERENCES
C. Berge, Hypergraphs, Elsevier Science Publisher,
Amsterdam, 1989.
D.D. Chamberlin, J. Robie and D. Florescu, Quilt: An
XML Query Language for Heterogeneous Data
Sources, WebDB 2000.
A. Deutsch, M. Fernadez, D. Florescu, A Levy, and D.
Suciu, XML-QL: A Query Language for XML,
Technical report, World Wide Web Consortium, 1989,
http://www.w3.org/TR/Note-xml-ql.
D. Florescu and D. Kossman, Storing and Querying XML
Data using an RDBMS. IEEE Data Engineering
Bulletin, 22(3), 1999.
http://www.w3.org/TR/xpath.
D.E. Knuth, The Art of Computer Programming, Vol. 1,
Addison-Wesley, Reading, MA, 1969.
P. Ramanan, Efficient Algorithms for Minimizing Tree
Pattern Queries, ACM SIGMOD 2002, June 2002,
Madison, Wisconsin, USA.
J. Robie, J. Lapp, and D. Schach, XML Query Language
(XQL), 1998. http://www.w3.org/TandS/
QL/QL98/pp/ xql.html.
World Wide Web Consortium, Extensible Markup
Language (XML) 1.0. http//www.w3.org/TR/1998/
REC-xml/ 19980210, Febuary 1998.
World Wide Web Consortium, Extensible Style Language
(XML) Working Draft, Dec. 1998.
http//www.w3.org/TR/ 1998/WD-xsl-19981216.
G. Gottlob, C. Koch, and R. Pichler, Efficient Algorithms
for Processing XPath Queries, ACM Transaction on
Database Systems, Vol. 30, No. 2, June 2005, pp. 444-
491.
G. Gottlob, C. Koch, and K.U. Schulz, Conjunctive
Queries over Trees, in Proc. PODS 2004, June 2004,
Paris, France, pp. 189-200.
H. Wang, S. Park, W. Fan, and P.S. Yu, ViST: A Dynamic
Index Method for Querying XML Data by Tree
Structures, SIGMOD Int. Conf. on Management of
Data, San Diego, CA., June 2003.
H. Wang and X. Meng, On the Sequencing of Tree
Structures for XML Indexing, in Proc. Conf. Data
Engineering, Tokyo, Japan, April, 2005, pp. 372-385.
C. Zhang, J. Naughton, D. DeWitt, Q. Luo and G.
Lohman, “On Supporting Containment Queries in
Relational Database Management Systems, in Proc. of
ACM SIGMOD Intl. Conf. on Management of Data,
California, USA, 2001.
ON THE EVALUATION OF TREE PATTERN QUERIES
85