Database Reference
In-Depth Information
Algorithm 15.4 I
NL
Q
UERY
(
Q
,
D
)
Require:
Q
is compatible with
D
.
Ensure: The returned query is a conjunctive query over I
NL
S
CHEMA
(
D
).
if
Q
=
then
return I
NL
P
ATTERN
(
π
π
,
D
)
else if
Q
=
Q
1
∧
Q
2
then
return I
NL
Q
UERY
(
Q
1
,
D
)
∧
I
NL
Q
UERY
(
Q
2
,
D
)
else if
Q
=
∃
xQ
1
then
return
∃
x
I
NL
Q
UERY
(
Q
1
,
D
)
end if
Proposition 15.9
Given a DTD D, a tree T that conforms to it, and a compatible query
Qin
CTQ(
↓
,
=)
, we have
Q
(
T
)=I
NL
Q
UERY
(
Q
,
D
)
I
NL
D
OC
(
T
,
D
)
.
Inlining XML schema mappings
A very similar approach can be used for inlining schema mappings: once we have inlining
of patterns and DTDs, we just combine them to generate relational mappings.
Recall that we deal with schema mappings from the class SM
nr
(
↓
,
=), i.e., mappings
M
Σ
st
), where the source and target DTDs
D
s
and
D
t
are nested-relational, and
Σ
st
is a set of st-tgds of the form
=(
D
s
,
D
t
,
π
(
x
,
z
) where
π
are patterns that use
π
(
x
,
y
)
→∃
z
π
and
only child navigation.
The following procedure generates a relational mapping I
NL
M
AP
(
M
) specified with a
set of source-to-target tuple generating dependencies. We write
X
←
Y
as a shortcut for
X
:=
X
∪
Y
.
M
Algorithm 15.5 I
NL
M
AP
(
)
Require: An XML mapping
st
).
Ensure: A relational mapping from I
NL
S
CHEMA
(
D
s
)toI
NL
S
CHEMA
(
D
t
).
I
NL
M
AP
(
M
=(
D
s
,
D
t
,
Σ
) := 0
for all dependencies
M
z
π
(
x
,
z
) in
π
(
x
,
y
)
→∃
Σ
st
do
I
NL
Q
UERY
(
π
,
D
t
)(
x
,
z
)
I
NL
M
AP
(
M
)
←
π
,
D
s
)(
x
,
y
)
→∃
z
I
NL
Q
UERY
(
end forreturn I
NL
M
AP
(
M
)
This procedure ensures that Requirement 4 holds. Recall that in part (b) of this require-
ment, relational universal solutions are only required to contain a shredding of an XML
universal solution. This is because relational solutions are also open to adding arbitrary
tuples, which need not reflect the tree structure of an XML document.
Σ
st
)
be an XML schema mapping in
SM
nr
(
Proposition 15.10
Let
M
=(
D
s
,
D
t
,
↓
,
=)
and
T an XML document that conforms to D
s
. Then: