





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






























Containment Mappings
Canonical Databases
Sariaya’s Algorithm
docsity.com
A CQ is a single Datalog rule, with all subgoals assumed to be EDB.
of a CQ is the mapping from
databases (the EDB) to the relationproduced for the head predicate byapplying that rule to the EDB.
docsity.com
Whenever there is a path from
to
it must be that
has an arc out, and
an arc in.
Thus, every fact (tuple) produced by Q1 is also produced by Q2.
That is, Q
docsity.com
Important optimization: if we can break a query into terms that are CQ’s, wecan eliminate those terms contained inanother.
Especially important when we deal withintegration of information: CQ containmentis almost the only way to tell whatinformation from sources we don’t
need.
docsity.com
Although CQ theory first appeared at a database conference, the AI communityhas taken CQ’s to heart.
CQ’s, or similar logics like description logic, are used in a number of AIapplications.
Again --- their design theory is reallycontainment and equivalence.
docsity.com
Two approaches:
Containment mappings.
Canonical databases.
Really the same in the simple CQ casecovered so far.
Containment is NP-complete, but CQ’stend to be small so here is one casewhere intractability doesn’t hurt you.
docsity.com
There is a containment mapping from Q2 to Q1 if and only if Q
Note that the containment mapping is opposite the containment --- it goesfrom the larger (containing CQ) to thesmaller (contained CQ).
docsity.com
p(X,Y):-r(X,Z)
g(Z,Z)
r(Z,Y)
p(A,B):-r(A,C)
g(C,D)
r(D,B)
Q1 looks for: Q2 looks for:
X
Y
Z
A
B
D
C
Since C=D is possible,expect Q
⊆
Q2.
docsity.com
p(X,Y):-r(X,Z)
g(Z,Z)
r(Z,Y)
p(A,B):-r(A,C)
g(C,D)
r(D,B)
No containment mapping from Q1 to Q2.
g(Z,Z) can only be mapped to g(C,D).
g
subgoals in Q2.
But then Z
must map to both C and D ---
impossible.
Thus, Q1 properly contained in Q2.
docsity.com
p(X,Y):-r(X,Y)
g(Y,Z)
p(A,B):-r(A,B)
r(A,C)
Q1 looks for:Q2 looks for:
X
Z
Y
A
B C
docsity.com
16
p(X,Y):-r(X,Y)
g(Y,Z)
p(A,B):-r(A,B)
r(A,C)
No containment mapping from Q1 to Q2.
g(Y,Z) cannot map anywhere, since there is no
g
subgoal in Q2.
Thus, Q1 properly contained in Q2.
docsity.com
First, assume there is a CM
Let
be any database; we must show
that Q1(
Suppose
is a tuple in Q1(
show
is also in Q2(
docsity.com
19
Consider the effect of applying
and
then
to Q2.
head of Q2 :-
subgoal of Q
head of Q1 :-
subgoal of Q
tuple of
s
°
m
maps
each sub-goal of Q2to a tupleof
D.
And the head of Q2 becomest, proving
t is also in Q2(
D); i.e., Q
⊆
Q2.
docsity.com
Now, we must assume Q
Q2, and
show there is a containment mappingfrom Q2 to Q1.
Key idea --- frozen
For each variable of
Q, create a
corresponding, unique constant.
Frozen
Q is a DB with one tuple formed
from each subgoal of
Q, with constants in
place of variables.
docsity.com