view based query determinacy and rewritings over graph
play

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


  1. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) Q ⇒ R � z ′ y x z 16 / 38

  2. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) Q ⇒ R � R ⇒ Q z ′ y x z 16 / 38

  3. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) Q ⇒ R � R ⇒ Q y z ′ y x z x 16 / 38

  4. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) Q ⇒ R � R ⇒ Q y z ′ y x z x z 16 / 38

  5. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) Q ⇒ R � R ⇒ Q y z ′ y z ′ x z x z 16 / 38

  6. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) Q ⇒ R � R ⇒ Q y z ′ y z ′ x z x z 16 / 38

  7. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) Q ⇒ R � R ⇒ Q y z ′ y z ′ x z x z 16 / 38

  8. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) Q ⇒ R � R ⇒ Q � y z ′ y z ′ x z x z 16 / 38

  9. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 [Afrati] V 3 = � a 3 � V 4 = � a 4 � Q 5 = � a 5 � R( x , y ) = ∃ z , V 4 ( x , z ) ∧ ( ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( z ′ , y )) R ′ ( x , y ) = ∃ z , t , V 4 ( x , z ) ∧ V 3 ( x , t ) ∧ ∀ z ′ V 3 ( z ′ , z ) ⇒ V 4 ( 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

  10. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Certain answers [Abiteboul, Duschka] cert exact � Q , V (E) = Q(D) (exact views) D | V (D)=E cert sound � Q , V (E) = Q(D) (sound views) D | V (D) ⊇ E 17 / 38

  11. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Certain answers [Abiteboul, Duschka] cert exact � Q , V (E) = Q(D) (exact views) D | V (D)=E cert sound � Q , V (E) = Q(D) (sound views) D | V (D) ⊇ E Remarks If V determines Q, then cert exact is a rewriting. Q , V cert Q , V ( · ) has coNP-complete data complexity. 17 / 38

  12. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Certain answers [Abiteboul, Duschka] cert exact � Q , V (E) = Q(D) (exact views) D | V (D)=E cert sound � Q , V (E) = Q(D) (sound views) D | V (D) ⊇ E Remarks If V determines Q, then cert exact is a rewriting. Q , V cert Q , 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. → cert exact is likely not optimal! Q , V 17 / 38

  13. 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

  14. 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

  15. 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

  16. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Monotone Determinacy 20 / 38

  17. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Example 2 revisited V 3 = � a 3 � V 4 = � a 4 � Q = � a 5 � V ։ Q but f is not monotone. V (D) ⊆ V (D ′ ) but Q(D ′ ) = ∅ Q(D) = { ( x 0 , x 5 ) } x 1 x 5 x 2 x 0 x 1 x 2 x 3 x 4 x 5 x 0 x 3 x 4 D ′ D 21 / 38

  18. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Monotone determinacy V ։ Q and f is monotone. Equivalently: V (D) ⊆ V (D ′ ) ⇒ Q(D) ⊆ Q(D ′ ) ∀ D , 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 cert sound is a rewriting. Q , V → Idea: look for approximations of cert sound Q , V . 22 / 38

  19. 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 h E − → 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 T Q , V such that, for all D, ( u , v ) ∈ cert sound Q , V ( V (D)) ⇔ ( V (D) , u , v ) / ∈ CSP( T Q , V ) 23 / 38

  20. 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

  21. 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

  22. 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

  23. 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

  24. 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

  25. 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

  26. 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

  27. 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

  28. 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

  29. 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

  30. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy A CSP approximation: the ( ℓ, k )-two-player-game Then Player 1 wins. u WIN LOSS v E T 24 / 38

  31. 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

  32. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Approximations The game on T Q , V over-approximates CSP( T Q , V ). → If ( E , u , v ) ∈ CSP( T Q , V ), then P2 has a winning strategy. The game on T Q , V under-approximates cert sound Q , V . → If P1 has a winning strategy, then ( u , v ) ∈ cert sound 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 on (E , u , v ) and T Q , V . 25 / 38

  33. 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 ) ∈ cert sound 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

  34. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy V ։ Q and f ր 27 / 38

  35. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy V ։ Q and f ր . . . Certain answers are a (coNP-hard) rewriting. 27 / 38

  36. 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

  37. 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

  38. 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

  39. 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

  40. 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

  41. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Asymptotic Determinacy 28 / 38

  42. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Restricted setting Graph databases → Graphs Regular path queries → Single path queries Notation: � a k � → � k � Regular path views “ → ” Union of single path queries Notation: � a i , a j � → � i , j � 29 / 38

  43. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Restricted setting Graph databases → Graphs Regular path queries → Single path queries Notation: � a k � → � k � Regular path views “ → ” Union of single path queries Notation: � a i , a j � → � i , j � Example 3 V 2 = � 2 � V 1 , 2 = � 1 , 2 � V 2 , 3 = � 2 , 3 � Q 3 = � 3 � Q 5 = � 5 � V � ։ Q 3 V ։ Q 5 29 / 38

  44. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Key observation 1 If V ։ Q k then ∃ c , Q c ∈ V . 30 / 38

  45. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Key observation 1 If V ։ Q k then ∃ c , Q c ∈ V . By contraposition, if ∀ c , Q c / ∈ V , then V � ։ Q k . Proof by example, with V 2 , 4 � ։ Q 4 . x 0 x 1 x 2 x 3 x 4 30 / 38

  46. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Key observation 1 If V ։ Q k then ∃ c , Q c ∈ V . By contraposition, if ∀ c , Q c / ∈ V , then V � ։ Q k . Proof by example, with V 2 , 4 � ։ Q 4 . V 2 , 4 x 0 x 1 x 2 x 3 x 4 30 / 38

  47. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Key observation 1 If V ։ Q k then ∃ c , Q c ∈ V . By contraposition, if ∀ c , Q c / ∈ V , then V � ։ Q k . Proof by example, with V 2 , 4 � ։ Q 4 . x 0 x 1 x 2 x 3 x 4 30 / 38

  48. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Key observation 1 If V ։ Q k then ∃ c , Q c ∈ V . By contraposition, if ∀ c , Q c / ∈ V , then V � ։ Q k . Proof by example, with V 2 , 4 � ։ Q 4 . x 0 x 1 x 2 x 3 x 4 V 2 , 4 30 / 38

  49. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Key observation 1 If V ։ Q k then ∃ c , Q c ∈ V . By contraposition, if ∀ c , Q c / ∈ V , then V � ։ Q k . Proof by example, with V 2 , 4 � ։ Q 4 . x 0 x 1 x 2 x 3 x 4 30 / 38

  50. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Key observation 1 If V ։ Q k then ∃ c , Q c ∈ V . By contraposition, if ∀ c , Q c / ∈ V , then V � ։ Q k . Proof by example, with V 2 , 4 � ։ Q 4 . x 0 x 1 x 2 x 3 x 4 30 / 38

  51. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Key observation 1 If V ։ Q k then ∃ c , Q c ∈ V . By contraposition, if ∀ c , Q c / ∈ V , then V � ։ Q k . Proof by example, with V 2 , 4 � ։ Q 4 . x 0 x 1 x 2 x 3 x 4 Key observation 2 If V ։ Q k then V ։ Q k + c . 30 / 38

  52. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Observations 1 & 2 → possible behaviors for a view V : 31 / 38

  53. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Observations 1 & 2 → possible behaviors for a view V : V ։ ? Q 1 Q 2 Q 3 Q 4 Q 5 Q c . . . 31 / 38

  54. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Observations 1 & 2 → possible behaviors for a view V : V ։ ? Q 1 Q 2 Q 3 Q 4 Q 5 Q c . . . Q 1+ c Q 2+ c Q 3+ c Q 4+ c Q 5+ c Q 2 c . . . 31 / 38

  55. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Observations 1 & 2 → possible behaviors for a view V : V ։ ? Q 1 Q 2 Q 3 Q 4 Q 5 Q c . . . Q 1+ c Q 2+ c Q 3+ c Q 4+ c Q 5+ c Q 2 c . . . Q 1+2 c Q 2+2 c Q 3+2 c Q 4+2 c Q 5+2 c Q 3 c . . . 31 / 38

  56. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Observations 1 & 2 → possible behaviors for a view V : V ։ ? Q 1 Q 2 Q 3 Q 4 Q 5 Q c . . . Q 1+ c Q 2+ c Q 3+ c Q 4+ c Q 5+ c Q 2 c . . . Q 1+2 c Q 2+2 c Q 3+2 c Q 4+2 c Q 5+2 c Q 3 c . . . Q 1+3 c Q 2+3 c Q 3+3 c Q 4+3 c Q 5+3 c Q 4 c . . . 31 / 38

  57. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Observations 1 & 2 → possible behaviors for a view V : V ։ ? Q 1 Q 2 Q 3 Q 4 Q 5 Q c . . . Q 1+ c Q 2+ c Q 3+ c Q 4+ c Q 5+ c Q 2 c . . . Q 1+2 c Q 2+2 c Q 3+2 c Q 4+2 c Q 5+2 c Q 3 c . . . Q 1+3 c Q 2+3 c Q 3+3 c Q 4+3 c Q 5+3 c Q 4 c . . . . . . . . . . . . . . . . . . . . . Q 1+ α c Q 2+ α c Q 3+ α c Q 4+ α c Q 5+ α c Q c + α c . . . . . . . . . . . . . . . . . . . . . 31 / 38

  58. Introduction Determinacy and Query Rewriting Monotone Determinacy Asymptotic Determinacy Observations 1 & 2 → possible behaviors for a view V : V ։ ? Q 1 Q 2 Q 3 Q 4 Q 5 Q c . . . Q 1+ c Q 2+ c Q 3+ c Q 4+ c Q 5+ c Q 2 c . . . Q 1+2 c Q 2+2 c Q 3+2 c Q 4+2 c Q 5+2 c Q 3 c . . . Q 1+3 c Q 2+3 c Q 3+3 c Q 4+3 c Q 5+3 c Q 4 c . . . . . . . . . . . . . . . . . . . . . Q 1+ α c Q 2+ α c Q 3+ α c Q 4+ α c Q 5+ α c Q c + α c . . . . . . . . . . . . . . . . . . . . . Asymptotic determinacy problem Given V , produce full picture at some line α past stabilization. 31 / 38

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend