View-based query determinacy and rewritings over graph databases - - PowerPoint PPT Presentation

view based query determinacy and rewritings over graph
SMART_READER_LITE
LIVE PREVIEW

View-based query determinacy and rewritings over graph databases - - PowerPoint PPT Presentation

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy View-based query determinacy and rewritings over graph databases Nadime Francis LSV at ENS-Cachan, Inria Tuesday, December, 8th 1 / 38 Introduction


slide-1
SLIDE 1

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query determinacy and rewritings

  • ver graph databases

Nadime Francis

LSV at ENS-Cachan, Inria

Tuesday, December, 8th

1 / 38

slide-2
SLIDE 2

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Introduction

2 / 38

slide-3
SLIDE 3

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Biblioth` eque Fran¸ cois Mitterand 30 000 users 11 million documents 2000 new documents per day

3 / 38

slide-4
SLIDE 4

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Biblioth` eque Fran¸ cois Mitterand 30 000 users 11 million documents 2000 new documents per day On the Internet 1000 billion web pages Facebook: 55 million updates per day Twitter: 500 million tweets per day Google: 3.5 billion queries per day

3 / 38

slide-5
SLIDE 5

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Databases Store data Retrieve data / answer queries Provide services

4 / 38

slide-6
SLIDE 6

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Databases Store data Retrieve data / answer queries Provide services

4 / 38

slide-7
SLIDE 7

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Databases Store data Retrieve data / answer queries Provide services

4 / 38

slide-8
SLIDE 8

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Graph databases Nodes: individual data Edges: links between data Motivations Data naturally presented as graphs: → Social networks, Internet, crime detection, semantic Web. Queries: paths, cycles, connected components

5 / 38

slide-9
SLIDE 9

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Queries How can I go from Bagneux to Porte d’Orl´ eans? Does any trip require more than 3 changes? What stations are closest to both my wife’s and my work places?

6 / 38

slide-10
SLIDE 10

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Queries Who are the friends of my friends with whom I share a common interest? Who are my friends that know each other? How small is the world?

7 / 38

slide-11
SLIDE 11

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

8 / 38

slide-12
SLIDE 12

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

8 / 38

slide-13
SLIDE 13

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

8 / 38

slide-14
SLIDE 14

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

8 / 38

slide-15
SLIDE 15

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

8 / 38

slide-16
SLIDE 16

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

8 / 38

slide-17
SLIDE 17

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

8 / 38

slide-18
SLIDE 18

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

8 / 38

slide-19
SLIDE 19

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

Application: Query optimization and caching

9 / 38

slide-20
SLIDE 20

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

Application: Data integration

10 / 38

slide-21
SLIDE 21

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

View-based query processing

Application: Privacy and security

11 / 38

slide-22
SLIDE 22

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Determinacy and Query Rewriting

12 / 38

slide-23
SLIDE 23

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

D E = V(D) Q(D) Q V

13 / 38

slide-24
SLIDE 24

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

D E = V(D) Q(D) Q V

1 Can I get Q(D) from E? 13 / 38

slide-25
SLIDE 25

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

D E = V(D) Q(D) Q V f

1 Can I get Q(D) from E? 2 Does it work for all D? 13 / 38

slide-26
SLIDE 26

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

D E = V(D) Q(D) Q V R

1 Can I get Q(D) from E? 2 Does it work for all D? 3 If so, can I compute R?

(in what language?)

13 / 38

slide-27
SLIDE 27

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Setting D: Graph databases Q: Regular Path Queries (RPQ) V: Regular Path Views E: View instances and view images

14 / 38

slide-28
SLIDE 28

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Setting D: Graph databases Q: Regular Path Queries (RPQ) V: Regular Path Views E: View instances and view images John Jack friend piano likes likes Tom friend Lise friend likes climbing likes likes Anna friend likes poetry likes likes

14 / 38

slide-29
SLIDE 29

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Setting D: Graph databases Q: Regular Path Queries (RPQ) V: Regular Path Views E: View instances and view images a b b a a b b b a b b b

14 / 38

slide-30
SLIDE 30

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Setting D: Graph databases Q: Regular Path Queries (RPQ) V: Regular Path Views E: View instances and view images Queries Q = L for some regular language L Q(D) = {(x, y) ∈ D | x

w

− → y in D, with w ∈ L} Ex: Q = a∗, Q = a+b Special cases: Single path queries (SPQ): Q = w, Qi = ai Unions of single path queries (UPQ): Q = w1, . . . , wn

14 / 38

slide-31
SLIDE 31

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Setting D: Graph databases Q: Regular Path Queries (RPQ) V: Regular Path Views E: View instances and view images View V: set of queries. Ex: V2 = a2, V3 = a3, V = {V2, V3} a b b a a b b b a b b b V V3 V3 V2 V2 V2

14 / 38

slide-32
SLIDE 32

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Setting D: Graph databases Q: Regular Path Queries (RPQ) V: Regular Path Views E: View instances and view images Determinacy ∀D, D′ V(D) = V(D′) ⇒ Q(D) = Q(D′) Q, V f : function induced by Q using V

14 / 38

slide-33
SLIDE 33

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Setting D: Graph databases Q: Regular Path Queries (RPQ) V: Regular Path Views E: View instances and view images Determinacy ∀D, D′ V(D) = V(D′) ⇒ Q(D) = Q(D′) Q, V f : function induced by Q using V Rewriting Query R such that ∀D R(V(D)) = f (V(D))

14 / 38

slide-34
SLIDE 34

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 1 V3 = a3 Q4 = a4

15 / 38

slide-35
SLIDE 35

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 1 V3 = a3 Q4 = a4 The view does not determine the query. V V V3 V3

15 / 38

slide-36
SLIDE 36

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5

16 / 38

slide-37
SLIDE 37

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y))

16 / 38

slide-38
SLIDE 38

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R

16 / 38

slide-39
SLIDE 39

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y

16 / 38

slide-40
SLIDE 40

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z

16 / 38

slide-41
SLIDE 41

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′

16 / 38

slide-42
SLIDE 42

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′

16 / 38

slide-43
SLIDE 43

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′

16 / 38

slide-44
SLIDE 44

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′ R ⇒ Q

16 / 38

slide-45
SLIDE 45

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′ R ⇒ Q x y

16 / 38

slide-46
SLIDE 46

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′ R ⇒ Q x y z

16 / 38

slide-47
SLIDE 47

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′ R ⇒ Q x y z z′

16 / 38

slide-48
SLIDE 48

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′ R ⇒ Q x y z z′

16 / 38

slide-49
SLIDE 49

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′ R ⇒ Q x y z z′

16 / 38

slide-50
SLIDE 50

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) Q ⇒ R x y z z′ R ⇒ Q x y z z′

16 / 38

slide-51
SLIDE 51

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 [Afrati] V3 = a3 V4 = a4 Q5 = a5 R(x, y) = ∃z, V4(x, z) ∧ (∀z′V3(z′, z) ⇒ V4(z′, y)) R′(x, y) = ∃z, t, V4(x, z)∧V3(x, t) ∧ ∀z′V3(z′, z) ⇒ V4(z′, y) R′ is also a rewriting : ∀D, R(V(D)) = R′(V(D)) R and R′ behave differently outside of view images : ∃E, R(E) = R′(E)

16 / 38

slide-52
SLIDE 52

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Certain answers [Abiteboul, Duschka] certexact

Q,V (E) =

  • D | V(D)=E

Q(D) (exact views) certsound

Q,V (E) =

  • D | V(D)⊇E

Q(D) (sound views)

17 / 38

slide-53
SLIDE 53

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Certain answers [Abiteboul, Duschka] certexact

Q,V (E) =

  • D | V(D)=E

Q(D) (exact views) certsound

Q,V (E) =

  • D | V(D)⊇E

Q(D) (sound views) Remarks If V determines Q, then certexact

Q,V

is a rewriting. certQ,V(·) has coNP-complete data complexity.

17 / 38

slide-54
SLIDE 54

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Certain answers [Abiteboul, Duschka] certexact

Q,V (E) =

  • D | V(D)=E

Q(D) (exact views) certsound

Q,V (E) =

  • D | V(D)⊇E

Q(D) (sound views) Remarks If V determines Q, then certexact

Q,V

is a rewriting. certQ,V(·) has coNP-complete data complexity. Theorem [F., Segoufin, Sirangelo] If an RPQ view V determines an RPQ query Q, then there exist a rewriting of Q using V with NP data complexity, and one with coNP data complexity. → certexact

Q,V

is likely not optimal!

17 / 38

slide-55
SLIDE 55

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Positive and negative results [Afrati]: Determinacy is decidable for single path queries and

  • views. Rewritings are in FO.

[Calvanese, De Giacomo, Lenzerini, Vardi]: Monotone determinacy is decidable for RPQ views and queries. [Nash, Segoufin, Vianu]: Determinacy is undecidable for UCQ views and queries. [F., Segoufin, Sirangelo]: Determinacy is undecidable for CRPQ views and RPQ queries. Open questions Decidability is still open for two key query languages:

Conjunctive queries and views. (WIP - [Marcinkowski et al.])

Regular path queries and views.

18 / 38

slide-56
SLIDE 56

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Main contributions

Theorem [ICDT 2014] If an RPQ view V determines an RPQ query Q in a monotone way, then there exists a Datalog rewriting of Q using V. → Cor: there exists a rewriting with PTime data complexity. → Cor: given V and Q, it is decidable whether there exists a Datalog rewriting of Q using V.

19 / 38

slide-57
SLIDE 57

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Main contributions

Theorem [ICDT 2014] If an RPQ view V determines an RPQ query Q in a monotone way, then there exists a Datalog rewriting of Q using V. → Cor: there exists a rewriting with PTime data complexity. → Cor: given V and Q, it is decidable whether there exists a Datalog rewriting of Q using V. Theorem [ICDT 2015, Best student paper] The asymptotic determinacy problem is decidable for UPQ views and SPQ queries over graphs, and results in first-order rewritings. → Cor: first-order is almost complete for rewritings of SPQ queries using UPQ views.

19 / 38

slide-58
SLIDE 58

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Monotone Determinacy

20 / 38

slide-59
SLIDE 59

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 2 revisited V3 = a3 V4 = a4 Q = a5 V ։ Q but f is not monotone. Q(D) = {(x0, x5)} V(D) ⊆ V(D′) but Q(D′) = ∅ x0 x1 x2 x3 x4 x5 x0 x1 x2 x3 x4 x5 D D′

21 / 38

slide-60
SLIDE 60

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Monotone determinacy V ։ Q and f is monotone. Equivalently: ∀D, D′ V(D) ⊆ V(D′) ⇒ Q(D) ⊆ Q(D′) Motivations Many interesting languages are monotone: conjunctive queries, regular path queries, Datalog, etc. [Nash, Segoufin, Vianu]: for CQ views and queries, monotone determinacy ⇒ CQ rewriting. Key observation If V determines Q in a monotone way, then certsound

Q,V

is a rewriting. → Idea: look for approximations of certsound

Q,V .

22 / 38

slide-61
SLIDE 61

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Constraint Satisfaction Problems as Queries Fix a template structure T with source and target nodes (E, u, v) ∈ CSP(T) iff there exists h such that

E

h

− → T h(u) is a source node h(v) is a target node

CSP(T) selects all u, v such that (E, u, v) ∈ CSP(T) Theorem [Calvanese, De Giacomo, Lenzerini, Vardi] There exists a structure TQ,V such that, for all D, (u, v) ∈ certsound

Q,V (V(D)) ⇔ (V(D), u, v) /

∈ CSP(TQ,V)

23 / 38

slide-62
SLIDE 62

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Arena : (E, u, v) and T with source and target nodes. u v E T

24 / 38

slide-63
SLIDE 63

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Player 1 starts by selecting k nodes on E. u v E T

24 / 38

slide-64
SLIDE 64

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Player 2 provides a homomorphism from those nodes to T. u v E T

24 / 38

slide-65
SLIDE 65

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Player 1 selects k nodes, keeping at most ℓ previous nodes. u v E T

24 / 38

slide-66
SLIDE 66

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Player 2 extends previous homomorphism to new nodes. u v E T

24 / 38

slide-67
SLIDE 67

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game If Player 1 selects u... u v E T

24 / 38

slide-68
SLIDE 68

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Then Player 2 must send it to a source node. u v E T

24 / 38

slide-69
SLIDE 69

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Similarly, if Player 1 selects v... u v E T

24 / 38

slide-70
SLIDE 70

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Then Player 2 must send it to a target node. u v E T

24 / 38

slide-71
SLIDE 71

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game If Player 2 has no legal move... u v E T

24 / 38

slide-72
SLIDE 72

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Then Player 1 wins. u v E T

WIN LOSS

24 / 38

slide-73
SLIDE 73

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

A CSP approximation: the (ℓ, k)-two-player-game Player 2 wins if she can play forever. u v E T

24 / 38

slide-74
SLIDE 74

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Approximations The game on TQ,V over-approximates CSP(TQ,V). → If (E, u, v) ∈ CSP(TQ,V), then P2 has a winning strategy. The game on TQ,V under-approximates certsound

Q,V .

→ If P1 has a winning strategy, then (u, v) ∈ certsound

Q,V (E).

Theorem [Feder, Vardi] There exists a Datalogℓ,k program Qℓ,k such that (u, v) ∈ Qℓ,k(E) if and only if Player 1 has a winning strategy for the game played

  • n (E, u, v) and TQ,V.

25 / 38

slide-75
SLIDE 75

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

The case of simple paths ∃ℓ, k such that Qℓ,k is exact on views of simple paths. (u, v) ∈ Qℓ,k(V(π)) if and only if (u, v) ∈ certsound

Q,V (V(π)).

  • This is the technical part of the proof!

Lifting paths to arbitrary databases Assume that some candidate query R is: a rewriting on views of simple paths, an under-approximation of a rewriting, closed under homomorphism. Then it is a rewriting on views of arbitrary databases.

26 / 38

slide-76
SLIDE 76

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

V ։ Q and f ր

27 / 38

slide-77
SLIDE 77

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

V ։ Q and f ր . . . Certain answers are a (coNP-hard) rewriting.

27 / 38

slide-78
SLIDE 78

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

V ։ Q and f ր . . . Certain answers are a (coNP-hard) rewriting. . . .

Certain answers ≡ ¬CSP [Calvanese et al.]

27 / 38

slide-79
SLIDE 79

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

V ։ Q and f ր . . . Certain answers are a (coNP-hard) rewriting. . . .

Certain answers ≡ ¬CSP [Calvanese et al.] . . . ¬CSP ∼ Qℓ,k in Datalog [Feder, Vardi]

27 / 38

slide-80
SLIDE 80

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

V ։ Q and f ր . . . Certain answers are a (coNP-hard) rewriting. . . .

Certain answers ≡ ¬CSP [Calvanese et al.] . . . ¬CSP ∼ Qℓ,k in Datalog [Feder, Vardi] . . . Qℓ,k is exact on simple paths, for some ℓ, k

27 / 38

slide-81
SLIDE 81

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

V ։ Q and f ր . . . Certain answers are a (coNP-hard) rewriting. . . .

Certain answers ≡ ¬CSP [Calvanese et al.] . . . ¬CSP ∼ Qℓ,k in Datalog [Feder, Vardi] . . . Qℓ,k is exact on simple paths, for some ℓ, k . . . Paths can be lifted to arbitrary databases.

27 / 38

slide-82
SLIDE 82

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

V ։ Q and f ր . . . Certain answers are a (coNP-hard) rewriting. . . .

Certain answers ≡ ¬CSP [Calvanese et al.] . . . ¬CSP ∼ Qℓ,k in Datalog [Feder, Vardi] . . . Qℓ,k is exact on simple paths, for some ℓ, k . . . Paths can be lifted to arbitrary databases. . . . Qℓ,k is a (PTime) rewriting.

27 / 38

slide-83
SLIDE 83

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Asymptotic Determinacy

28 / 38

slide-84
SLIDE 84

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Restricted setting Graph databases → Graphs Regular path queries → Single path queries Notation: ak → k Regular path views “→” Union of single path queries Notation: ai, aj → i, j

29 / 38

slide-85
SLIDE 85

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Restricted setting Graph databases → Graphs Regular path queries → Single path queries Notation: ak → k Regular path views “→” Union of single path queries Notation: ai, aj → i, j Example 3 V2 = 2 V1,2 = 1, 2 V2,3 = 2, 3 Q3 = 3 Q5 = 5 V ։ Q3 V ։ Q5

29 / 38

slide-86
SLIDE 86

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Key observation 1 If V ։ Qk then ∃c, Qc ∈ V.

30 / 38

slide-87
SLIDE 87

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Key observation 1 If V ։ Qk then ∃c, Qc ∈ V. By contraposition, if ∀c, Qc / ∈ V, then V ։ Qk. Proof by example, with V2,4 ։ Q4. x0 x1 x2 x3 x4

30 / 38

slide-88
SLIDE 88

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Key observation 1 If V ։ Qk then ∃c, Qc ∈ V. By contraposition, if ∀c, Qc / ∈ V, then V ։ Qk. Proof by example, with V2,4 ։ Q4. x0 x1 x2 x3 x4 V2,4

30 / 38

slide-89
SLIDE 89

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Key observation 1 If V ։ Qk then ∃c, Qc ∈ V. By contraposition, if ∀c, Qc / ∈ V, then V ։ Qk. Proof by example, with V2,4 ։ Q4. x0 x1 x2 x3 x4

30 / 38

slide-90
SLIDE 90

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Key observation 1 If V ։ Qk then ∃c, Qc ∈ V. By contraposition, if ∀c, Qc / ∈ V, then V ։ Qk. Proof by example, with V2,4 ։ Q4. x0 x1 x2 x3 x4 V2,4

30 / 38

slide-91
SLIDE 91

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Key observation 1 If V ։ Qk then ∃c, Qc ∈ V. By contraposition, if ∀c, Qc / ∈ V, then V ։ Qk. Proof by example, with V2,4 ։ Q4. x0 x1 x2 x3 x4

30 / 38

slide-92
SLIDE 92

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Key observation 1 If V ։ Qk then ∃c, Qc ∈ V. By contraposition, if ∀c, Qc / ∈ V, then V ։ Qk. Proof by example, with V2,4 ։ Q4. x0 x1 x2 x3 x4

30 / 38

slide-93
SLIDE 93

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Key observation 1 If V ։ Qk then ∃c, Qc ∈ V. By contraposition, if ∀c, Qc / ∈ V, then V ։ Qk. Proof by example, with V2,4 ։ Q4. x0 x1 x2 x3 x4 Key observation 2 If V ։ Qk then V ։ Qk+c.

30 / 38

slide-94
SLIDE 94

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Observations 1 & 2 → possible behaviors for a view V:

31 / 38

slide-95
SLIDE 95

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Observations 1 & 2 → possible behaviors for a view V:

V ։?

Q1 Q2 Q3 Q4 Q5 . . . Qc

31 / 38

slide-96
SLIDE 96

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Observations 1 & 2 → possible behaviors for a view V:

V ։?

Q1 Q2 Q3 Q4 Q5 . . . Qc Q1+c Q2+c Q3+c Q4+c Q5+c . . . Q2c

31 / 38

slide-97
SLIDE 97

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Observations 1 & 2 → possible behaviors for a view V:

V ։?

Q1 Q2 Q3 Q4 Q5 . . . Qc Q1+c Q2+c Q3+c Q4+c Q5+c . . . Q2c Q1+2c Q2+2c Q3+2c Q4+2c Q5+2c . . . Q3c

31 / 38

slide-98
SLIDE 98

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Observations 1 & 2 → possible behaviors for a view V:

V ։?

Q1 Q2 Q3 Q4 Q5 . . . Qc Q1+c Q2+c Q3+c Q4+c Q5+c . . . Q2c Q1+2c Q2+2c Q3+2c Q4+2c Q5+2c . . . Q3c Q1+3c Q2+3c Q3+3c Q4+3c Q5+3c . . . Q4c

31 / 38

slide-99
SLIDE 99

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Observations 1 & 2 → possible behaviors for a view V:

V ։?

Q1 Q2 Q3 Q4 Q5 . . . Qc Q1+c Q2+c Q3+c Q4+c Q5+c . . . Q2c Q1+2c Q2+2c Q3+2c Q4+2c Q5+2c . . . Q3c Q1+3c Q2+3c Q3+3c Q4+3c Q5+3c . . . Q4c . . . . . . . . . . . . . . . . . . Q1+αc Q2+αc Q3+αc Q4+αc Q5+αc . . . Qc+αc . . . . . . . . . . . . . . . . . .

31 / 38

slide-100
SLIDE 100

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Observations 1 & 2 → possible behaviors for a view V:

V ։?

Q1 Q2 Q3 Q4 Q5 . . . Qc Q1+c Q2+c Q3+c Q4+c Q5+c . . . Q2c Q1+2c Q2+2c Q3+2c Q4+2c Q5+2c . . . Q3c Q1+3c Q2+3c Q3+3c Q4+3c Q5+3c . . . Q4c . . . . . . . . . . . . . . . . . . Q1+αc Q2+αc Q3+αc Q4+αc Q5+αc . . . Qc+αc . . . . . . . . . . . . . . . . . .

Asymptotic determinacy problem Given V, produce full picture at some line α past stabilization.

31 / 38

slide-101
SLIDE 101

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Main theorem restated Given a UPQ view V, we can: Compute some α past stabilization; Produce first-order rewritings for determined queries after α; Produce counter-examples for all other queries after α.

Note that these work also before α, due to Obs. 2.

32 / 38

slide-102
SLIDE 102

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Main theorem restated Given a UPQ view V, we can: Compute some α past stabilization; Produce first-order rewritings for determined queries after α; Produce counter-examples for all other queries after α.

Note that these work also before α, due to Obs. 2.

V ։?

Q1 Q2 Q3 Q4 Q5 . . . Qc Q1+c Q2+c Q3+c Q4+c Q5+c . . . Q2c Q1+2c Q2+2c Q3+2c Q4+2c Q5+2c . . . Q3c Q1+3c Q2+3c Q3+3c Q4+3c Q5+3c . . . Q4c . . . . . . . . . . . . . . . . . . Q1+αc Q2+αc Q3+αc Q4+αc Q5+αc . . . Qc+αc . . . . . . . . . . . . . . . . . . 32 / 38

slide-103
SLIDE 103

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5

33 / 38

slide-104
SLIDE 104

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5 V ։

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 33 / 38

slide-105
SLIDE 105

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5 V ։

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12

V ։ Q2k for all k.

33 / 38

slide-106
SLIDE 106

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5 V ։

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12

V ։ Q2k for all k. V ։ Q11.

33 / 38

slide-107
SLIDE 107

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5 V ։

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12

V ։ Q2k for all k. V ։ Q11. V ։ Q1, Q3, Q5, Q7.

33 / 38

slide-108
SLIDE 108

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5 V ։

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12

V ։ Q2k for all k. V ։ Q11. V ։ Q1, Q3, Q5, Q7. x0 x1 x2 x3 x4 x5 x6 x7 y0 y1 y2 y3 y4 y5 y6 y7

33 / 38

slide-109
SLIDE 109

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5 V ։

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12

V ։ Q2k for all k. V ։ Q11. V ։ Q1, Q3, Q5, Q7. x0 y1 x2 y3 x4 y5 x6 y7 y0 x1 y2 x3 y4 x5 y6 x7

33 / 38

slide-110
SLIDE 110

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5 V ։

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12

What about Q9?

34 / 38

slide-111
SLIDE 111

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Example 4 V2 = 2 V1,2 = 1, 2 V2,5 = 2, 5 V ։

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12

What about Q9?

V ։ Q9!

34 / 38

slide-112
SLIDE 112

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Perspectives

35 / 38

slide-113
SLIDE 113

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Questions left open

On regular path queries and regular path views Monotone determinacy is decidable. What about general determinacy? → Decidability: unknown. → Answering: best known bounds: NP∩coNP. On unions of single path queries Asymptotic determinacy is decidable for UPQ to SPQ. What about small queries? What about labelled graphs?

36 / 38

slide-114
SLIDE 114

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Related questions

On rewriting languages What is a good language for rewriting?

For RPQ queries and views: unknown. For SPQ queries and UPQ views: FO?

Here: tool for achieving complexity bounds. Other relevant properties? On the connexion between Datalog and CSP [Barto]: If CSP(T) is solvable in Datalog, it is solvable in Datalog2,3. Here: CSP(TQ,V) is solvable in Datalogℓ,k, but on restricted

  • domain. Can we do better?

37 / 38

slide-115
SLIDE 115

Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy

Thank you!

38 / 38

slide-116
SLIDE 116

Appendix

1 / 3

slide-117
SLIDE 117

Example 3 V2 = 2 V1,2 = 1, 2 V2,3 = 2, 3 Q3 = 3 Q5 = 5

2 / 3

slide-118
SLIDE 118

Example 3 V2 = 2 V1,2 = 1, 2 V2,3 = 2, 3 Q3 = 3 Q5 = 5 V ։ Q3 x0 x1 x2 x3 y0 y1 y2 y3 u v w z x0 y1 x2 y3 y0 x1 y2 x3 u v w z

2 / 3

slide-119
SLIDE 119

Example 3 V2 = 2 V1,2 = 1, 2 V2,3 = 2, 3 Q3 = 3 Q5 = 5 V ։ Q5 R(x, y) = ∃x0, x1, x2, x3, x4, x5, x = x0 ∧ y = x5

  • i V2(xi, xi+2)
  • i V1,2(xi, xi+1) ∧ V1,2(xi, xi+2)
  • i V2,3(xi, xi+2) ∧ V2,3(xi, xi+3)

∀z, V1,2(z, x3) ⇒ V2(z, x3) ∨ V2(z, x4)

2 / 3

slide-120
SLIDE 120

Example 5 V1 = a, aa V2 = aa, aaa Q = a(a6)∗ | aa(a6)∗ R(x, y) = ∃z V1(x, z) ∧ T ∗(z, y) where T(x, y) is defined as : x y z1 z2 V1 V1 V1 V2 V2 V2

3 / 3