Database Reference
In-Depth Information
rulers
ruler
(
James V
)
ruler
(
Mary I
)
ruler
(
James VI & I
)
ruler
(
Elizabeth I
)
successor
(
Mary I)
successor
(
James VI & I
)
successor
(
Charles I
)
successor
(
James VI & I
)
(a)
T
2
, a solution for
T
1
rulers
ruler
(
James V
)
ruler
(
Mary I
)
ruler
(
James VI & I
)
ruler
(
Louis XIII
)
ruler
(
Elizabeth I
)
ruler
(
James VI & I
)
successor
(
Mary I
)
successor
(
James VI & I
)
successor
(
Charles I
)
successor
(
Charles I
)
successor
(
James VI & I
)
successor
(
⊥
)
(b)
T
3
, another possible solution for
T
1
Figure 11.4 Solutions for
T
1
under
M
A natural solution for
T
1
in
Figure 10.1
is the tree
T
2
in
Figure 11.4
(a). As we already
know, every tree obtained from
T
2
by adding new children with arbitrary data values, or by
permuting the existing children, is also a solution for
T
1
. For instance,
T
3
in
Figure 11.4
(b)
is as good a solution for
T
1
as any. On the other hand, according to the schema, each
ruler
node should only have one
successor
child. So, merging the two
James VI & I
nodes in
T
3
would not give a solution.
The XML mappings we have just defined naturally generalize the usual relational map-
pings. If we have relational schemas R
s
and R
t
, they can be represented as regular schemas
S
s
and
S
t
: for example, for R
s
=
{
S
1
(
A
,
B
)
,
S
2
(
C
,
D
)
}
, the schema
S
s
is the following
DTD
r
→
s
1
s
2
t
1
s
1
→
t
1
:@
A
,
@
B
t
2
s
2
→
t
2
:@
C
,
@
D
.
Then each conjunctive query over a relational schema is easily translated into a pattern over
the corresponding DTD together with some equality constraints. For example, the query
Q
(
x
,
y
,
z
)=
S
1
(
x
,
y
)
∧
S
2
(
y
,
z
) will be translated into
r
[
s
1
/
t
1
(
x
,
y
1
)
,
s
2
/
t
2
(
y
2
,
z
)]
,
y
1
=
y
2
.
Of course equalities can be incorporated into the pattern (i.e., by
r
[
s
1
/
t
1
(
x
,
y
)
,
s
2
/
t
2
(
y
,
z
)])
but as we said, we often prefer to list them separately to make classification of different