Query Con tainmen t for Conjunctiv e Queries With Regular - - PowerPoint PPT Presentation

query con tainmen t for conjunctiv e queries with regular
SMART_READER_LITE
LIVE PREVIEW

Query Con tainmen t for Conjunctiv e Queries With Regular - - PowerPoint PPT Presentation

Query Con tainmen t for Conjunctiv e Queries With Regular Expressions Daniela Florescu, Alon Levy , Dan Suciu Query Con tainmen t for Conjunctiv e Queries With Regular Expressions Dan Suciu A T&T Labs 1 PODS'98


slide-1
SLIDE 1 Query Con tainmen t for Conjunctiv e Queries With Regular Expressions Daniela Florescu, Alon Levy , Dan Suciu Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 1
slide-2
SLIDE 2 Intr
  • duction
Semistructured Data. F eatures:
  • Do
es not t in to pre-existing, xed sc hema
  • Missing
attributes
  • A
ttributes
  • f
unkno wn cardinalities
  • Set
  • f
attributes unkno wn in adv ance
  • Irregular
nesting Query Languages for Semistructured Data. F eatures:
  • Lab
el v ariables
  • Regular
path expressions: recursiv e queries Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 2
slide-3
SLIDE 3 Motivation Curren t applications
  • f
semistructured data:
  • Data
in tegration [Tsimmis]
  • W
eb querying [W ebSQL, W ebOQL]
  • General-purp
  • se
[Lore, UnQL]
  • W
eb-site managemen t [Strudel] Query Con tainmen t needed in semistructured data for:
  • Chec
king in tegrit y constrain ts for W eb-sites [Strudel]
  • Query
rewriting to accomo date v ariet y
  • f
storage metho ds. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 3
slide-4
SLIDE 4 Pr evious Work
  • n
Query Containment and Equivalenc e Non-recursiv e Conjunctiv e Queries:
  • decidable
for conjunctiv e queries [Chandra and Merlin 77]
  • w/
union [Sagiv and Y annak akis 81]
  • w/
  • rder
and inequalities [Klug 88]
  • w/
nested relations [Levy and Suciu 97] Results
  • n
Recursiv e Queries:
  • undecidable
for Datalog [Sh umeli 93]
  • recursiv
e v.s. nonrecursiv e [Chaudh uri and V ardi 92]
  • sev
eral results
  • n
deciding b
  • unde
dness
  • f
recursiv e queries
  • No
p
  • sitiv
e results for true recursiv e queries. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 4
slide-5
SLIDE 5 Outline
  • Bac
kground (semistructured data and queries)
  • Denitions
  • Main
results
  • Con
tainmen t for simple regular expressions.
  • Con
tainmen t for arbitrary regular expressions.
  • Conclusions
Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 5
slide-6
SLIDE 6 Backgr
  • und:
Semistructur e d Data Denition Graph Database = Graph with lab eled edges

a b a c b d tup tup tup phone 5469 sue 2654 joe 1234 john name name phone name phone

Other p
  • ssible
v ariations: v alues attac hed to lea v es. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 6
slide-7
SLIDE 7 Backgr
  • und:
Query L anguages for Semistructur e d Data Languages: LOREL, UnQL, W ebSQL, W ebOQL, StruQL. Denition An atomic condition X R Y where X ; Y = v ariables, R = regular path expression. Examples: X a Y simple lab el X a:(bjc:d) Y a follo w ed b y b
  • r
b y c:d X a
  • :b
+ Y regular path expression X L:(a:L)
  • Y
lab el v ariables Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 7
slide-8
SLIDE 8 Conjunctive Queries with R e gular Expr essions Denition Q : q (
  • X
) : Y 1 R 1 Z 1 ; : : : ; Y n R n Z n Meaning
  • n
database D B : a k
  • ary
relation, where k =j
  • X
j. Example: q (L; Y ) : X (a:L) Y ; Y L Z

d d c d u1 u4 c a b c b c b b b u5 u10 u3 u8 u14

DB =

u2 u9 u7 u6 u11 u12 u13 u15 a

Q(D B ) L Y b u5 c u8 Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 8
slide-9
SLIDE 9 The Containment and Equivalenc e Pr
  • blems
Con tainmen t Giv en Q1; Q2 c hec k if 8D B ; Q1(D B )
  • Q2(D
B ) Equiv alence Giv en Q1; Q2 c hec k if 8D B ; Q1(D B ) = Q2(D B ) Example: Q1 : q 1(X ; Z ) :
  • X
a + Z Q2 : q 2(X ; Z ) :
  • X
L + Z ; Y aZ ; X (a + j(a:b
  • ))Z
Q1
  • Q2
Note Con tainmen t and Equiv alence Problem for regular expressions is PSP A CE-complete [Stokmey er and Mey er 1973]. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 9
slide-10
SLIDE 10 Main R esults Theorem Con tainmen t (and equiv alence)
  • f
conjunctiv e queries with regular path expressions is decidable in exp
  • nen
tial space. Theorem Con tainmen t (and equiv alence)
  • f
conjunctiv e queries with simple regular path expressions is NP-complete. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 10
slide-11
SLIDE 11 Simple R e gular Expr essions Denition R ::= r 1 :r 2 : : : r n where eac h r i is constan t
  • r
  • Examples
a:b:c a:
  • :c:
  • :a
:a:
  • :
  • :b
(= :a:
  • :b)
Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 11
slide-12
SLIDE 12 Containment
  • f
Conjunctive Queries with Simple R e gular Expr essions Con tainmen t test: Q
  • Q
i there exists a query mapping f : Q ! Q s.t.
  • X
aY mapp ed to similar condition X aY
  • X
  • Y
mapp ed to an y c hain X r Z 1 ; Z 1 r 1 Z 2 ; : : : ; Z n r n Y Example: X c Y ; Y ( :a)Z ; Y (b:d) U
  • X
  • Y
; Y a Z ; X
  • U
; U b W .

c b a * * * b d a

  • Hence:
NP-complete. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 12
slide-13
SLIDE 13 Do es Not Work in Gener al Case One query mapping is not sucien t: Q1 : q 1(X ) :
  • X
a
  • U;
U b V ; U (a:b) V Q2 : q 2(X ) :
  • X
((a:a)
  • :b)
Y Q1
  • Q2,
but it is \witnessed" b y t w
  • query
mappings.

X X a* (a.a)*.b

?

a.b b

Need to consider sev eral query mappings. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 13
slide-14
SLIDE 14 A nother Example q 1(X ) :
  • X
(a:)Y ; Y (b:c)Z ; Y cU q 2(X ) :
  • X
(a: :
  • :c)W
Need to map W either to Z
  • r
to U Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 14
slide-15
SLIDE 15 Canonic al Datab ases Denition Giv en Q1, a canonical database D B is
  • ne
  • btained
b y \expanding" the query graph. Example: Q1 : q 1(X ) : X a
  • U;
U b V ; U (a:b) V Q1 =

X a* b a.b

D B =

a b X a b a a a a

In general there are innitely man y canonical D B for Q1. Prop
  • sition
Q1
  • Q2
i
  • X
2 Q2(D B ) for all canonical databases. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 15
slide-16
SLIDE 16 Canonic al Datab ases and Query Mappings
  • Eac
h mapping f : Q2 ! Q1 pro v es
  • X
2 Q(D B ) for a certain set S f
  • f
canonical D B 's
  • There
are
  • nly
exp
  • nen
tially man y mappins f : Q2 ! Q1.
  • Hence:
to c hec k Q1
  • Q2
suces to c hec k that S f S f = all canonical databases.
  • Ho
w to compute S f ? Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 16
slide-17
SLIDE 17 Enc
  • ding
Canonic al D B 's as Wor ds Example Giv en query Q1 : q 1(X ) : X a
  • U;
U b V ; U (a:b) V Ob ject Enco ding Canonical D B :

a b X a b a a a a

w D B = a:a:a:a:a$b$a:b All canonical D B 's W Q1 = a
  • $b$a:b
Query Mapping f : Q2 ! Q1 W f enco des S f

X X a*

f1

(a.a)*.b a.b b

W f 1 = (a:a)
  • $b$a:b

X X a*

f2

(a.a)*.b a.b b

W f 2 = a:(a:a)
  • $b$a:b
Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 17
slide-18
SLIDE 18 Containment T est Prop
  • sition
Q1
  • Q2
i S f W f
  • W
Q1 Complexit y
  • there
are exp
  • nen
tially man y query mappings f
  • eac
h W f is
  • f
p
  • lynomial
size Hence: Exp
  • nen
tial Space Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 18
slide-19
SLIDE 19 Conclusions
  • Dened
usefull class
  • f
recursiv e queries for whic h con tainmen t is NP-complete.
  • More
general case: Con tainmen t decidable EXPSP A CE.
  • Op
en questions: can it b e done in PSP A CE ?
  • \Reasoning
b y cases" required.
  • Note:
conjunctiv e queries with r.e. not closed under comp
  • sition.
T
  • study
con tainmen t
  • f
comp
  • sed
queries.
  • Query
rewriting. Query Con tainmen t for Conjunctiv e Queries With Regular Expressions PODS'98 Dan Suciu A T&T Labs 19