semantics is an indispensable aspect of a query language
play

Semantics is an indispensable aspect of a query language Semantics - PowerPoint PPT Presentation

Semantics is an indispensable aspect of a query language Semantics is an indispensable aspect of a query language SELECT Name, Salary FROM Employees WHERE Salary >= 500000 Semantics is an indispensable aspect of a query language SELECT


  1. Compatible mappings: mappings that can be merged. Definition Mappings are compatibles if they agree in their common variables. Example ? X ? Y ? Z ? V µ 1 : R 1 john µ 2 : R 1 J@edu.ex µ 3 : P@edu.ex R 2 µ 1 ∪ µ 2 : R 1 john J@edu.ex µ 1 ∪ µ 3 : R 1 john P@edu.ex R 2

  2. Compatible mappings: mappings that can be merged. Definition Mappings are compatibles if they agree in their common variables. Example ? X ? Y ? Z ? V µ 1 : R 1 john µ 2 : R 1 J@edu.ex µ 3 : P@edu.ex R 2 µ 1 ∪ µ 2 : R 1 john J@edu.ex µ 1 ∪ µ 3 : R 1 john P@edu.ex R 2 ◮ µ 2 and µ 3 are not compatible

  3. Sets of mappings and operations Let M 1 and M 2 be sets of mappings: Definition

  4. Sets of mappings and operations Let M 1 and M 2 be sets of mappings: Definition Join: extends mappings in M 1 with compatible mappings in M 2

  5. Sets of mappings and operations Let M 1 and M 2 be sets of mappings: Definition Join: extends mappings in M 1 with compatible mappings in M 2 ◮ M 1 ⋊ ⋉ M 2 = { µ 1 ∪ µ 2 | µ 1 ∈ M 1 , µ 2 ∈ M 2 , and µ 1 , µ 2 are compatible }

  6. Sets of mappings and operations Let M 1 and M 2 be sets of mappings: Definition Join: extends mappings in M 1 with compatible mappings in M 2 ◮ M 1 ⋊ ⋉ M 2 = { µ 1 ∪ µ 2 | µ 1 ∈ M 1 , µ 2 ∈ M 2 , and µ 1 , µ 2 are compatible } Difference: selects mappings in M 1 that cannot be extended with mappings in M 2

  7. Sets of mappings and operations Let M 1 and M 2 be sets of mappings: Definition Join: extends mappings in M 1 with compatible mappings in M 2 ◮ M 1 ⋊ ⋉ M 2 = { µ 1 ∪ µ 2 | µ 1 ∈ M 1 , µ 2 ∈ M 2 , and µ 1 , µ 2 are compatible } Difference: selects mappings in M 1 that cannot be extended with mappings in M 2 ◮ M 1 � M 2 = { µ 1 ∈ M 1 | there is no mapping µ 2 ∈ M 2 compatible with µ 1 }

  8. Sets of mappings and operations Let M 1 and M 2 be sets of mappings: Definition

  9. Sets of mappings and operations Let M 1 and M 2 be sets of mappings: Definition Union: includes mappings in M 1 plus mappings in M 2 (set union) ◮ M 1 ∪ M 2 = { µ | µ ∈ M 1 or µ ∈ M 2 }

  10. Sets of mappings and operations Let M 1 and M 2 be sets of mappings: Definition Union: includes mappings in M 1 plus mappings in M 2 (set union) ◮ M 1 ∪ M 2 = { µ | µ ∈ M 1 or µ ∈ M 2 } Left Outer Join: considers mappings in M 1 extending them with compatible mappings in M 2 whenever it is possible ◮ M 1 M 2 = ( M 1 ⋊ ⋉ M 2 ) ∪ ( M 1 � M 2 )

  11. Semantics in terms of operations between evaluations Let M 1 and M 2 be the evaluation of P 1 and P 2 . Definition The evaluation of: ( P 1 AND P 2 ) → ( P 1 UNION P 2 ) → ( P 1 OPT P 2 ) →

  12. Semantics in terms of operations between evaluations Let M 1 and M 2 be the evaluation of P 1 and P 2 . Definition The evaluation of: ( P 1 AND P 2 ) → M 1 ⋊ ⋉ M 2 ( P 1 UNION P 2 ) → ( P 1 OPT P 2 ) →

  13. Semantics in terms of operations between evaluations Let M 1 and M 2 be the evaluation of P 1 and P 2 . Definition The evaluation of: ( P 1 AND P 2 ) → M 1 ⋊ ⋉ M 2 ( P 1 UNION P 2 ) → M 1 ∪ M 2 ( P 1 OPT P 2 ) →

  14. Semantics in terms of operations between evaluations Let M 1 and M 2 be the evaluation of P 1 and P 2 . Definition The evaluation of: ( P 1 AND P 2 ) → M 1 ⋊ ⋉ M 2 ( P 1 UNION P 2 ) → M 1 ∪ M 2 ( P 1 OPT P 2 ) → M 1 M 2

  15. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) )

  16. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) )

  17. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) ) ? X ? Y R 1 john R 2 paul

  18. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) ) ? X ? Y R 1 john R 2 paul

  19. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) ) ? X ? Y ? X ? E R 1 john R 1 J@ed.ex R 2 paul

  20. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) ) ? X ? Y ? X ? E R 1 john R 1 J@ed.ex R 2 paul

  21. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) ) ? X ? Y ? X ? Y ? E ? X ? E R 1 john R 1 john J@ed.ex R 1 J@ed.ex R 2 paul R 2 paul

  22. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) ) ? X ? Y ? X ? Y ? E ? X ? E R 1 john R 1 john J@ed.ex R 1 J@ed.ex R 2 paul R 2 paul ◮ from the Join

  23. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) ) ? X ? Y ? X ? Y ? E ? X ? E R 1 john R 1 john J@ed.ex R 1 J@ed.ex R 2 paul R 2 paul ◮ from the Join ◮ from the Difference

  24. Simple example Example ( R 1 , name, john) ( R 1 , email, J@ed.ex) ( R 2 , name, paul) ( (? X , name, ? Y ) OPT (? X , email, ? E ) ) ? X ? Y ? X ? Y ? E ? X ? E R 1 john R 1 john J@ed.ex R 1 J@ed.ex R 2 paul R 2 paul ◮ from the Join ◮ from the Difference ◮ from the Union

  25. Boolean filter expressions (value constraints) In filter expressions we consider ◮ equality (=) among variables and RDF terms ◮ unary predicate bound ◮ boolean combinations ( ∧ , ∨ , ¬ )

  26. Satisfaction of value constraints A mapping satisfies ◮ ? X = c if it gives the value c to variable ? X ◮ ? X =? Y if it gives the same value to ? X and ? Y ◮ bound(? X ) if it is defined for ? X

  27. Satisfaction of value constraints A mapping satisfies ◮ ? X = c if it gives the value c to variable ? X ◮ ? X =? Y if it gives the same value to ? X and ? Y ◮ bound(? X ) if it is defined for ? X Definition The evaluation of ( P FILTER R ): ◮ mappings in the evaluation of P that satisfy R .

  28. It was not that difficult to define a formal semantics for SPARQL

  29. It was not that difficult to define a formal semantics for SPARQL Key aspects: ◮ use partial mappings for individual solutions ◮ adapt classical operators to deal with partial mappings

  30. Outline Motivation Our contributions Syntax and semantics of SPARQL graph patterns Syntax Semantics Complexity results Well–designed graph patterns Complexity Normalization and optimization

  31. The evaluation decision problem INPUT: A mapping , a graph pattern , and an RDF graph . OUTPUT: Is the mapping in the evaluation of the pattern over the graph ?

  32. Evaluation of simple patterns is polynomial. Theorem For patterns using only AND and FILTER operators, the evaluation problem is polynomial: O ( size of the pattern × size of the graph ) .

  33. Evaluation of simple patterns is polynomial. Theorem For patterns using only AND and FILTER operators, the evaluation problem is polynomial: O ( size of the pattern × size of the graph ) . Proof idea ◮ Check that the mapping makes every triple to match. ◮ Then check that the mapping satisfies the FILTERs.

  34. Evaluation including UNION is NP-complete. Theorem For patterns using AND , FILTER and UNION operators, the evaluation problem is NP-complete.

  35. Evaluation including UNION is NP-complete. Theorem For patterns using AND , FILTER and UNION operators, the evaluation problem is NP-complete. Proof idea ◮ Reduction from propositional SAT ◮ The pattern codifies a propositional formula.

  36. Evaluation including UNION is NP-complete. Theorem For patterns using AND , FILTER and UNION operators, the evaluation problem is NP-complete. Proof idea ◮ Reduction from propositional SAT ◮ The pattern codifies a propositional formula. ◮ Using ¬ bound to codify negation.

  37. A simple normal from Theorem (UNION Normal Form) Every graph pattern is equivalent to one of the form P 1 UNION P 2 UNION · · · UNION P n with P i UNION –free.

  38. A simple normal from Theorem (UNION Normal Form) Every graph pattern is equivalent to one of the form P 1 UNION P 2 UNION · · · UNION P n with P i UNION –free. Theorem The evaluation problem for AND - FILTER - UNION patterns in UNION normal form, is polynomial.

  39. Evaluation in general is PSPACE-complete. Theorem For general patterns that include OPT operator, the evaluation problem is PSPACE-complete.

  40. Evaluation in general is PSPACE-complete. Theorem For general patterns that include OPT operator, the evaluation problem is PSPACE-complete. ◮ still PSPACE-complete for AND - FILTER - OPT patterns

  41. Evaluation in general is PSPACE-complete. Theorem For general patterns that include OPT operator, the evaluation problem is PSPACE-complete. ◮ still PSPACE-complete for AND - FILTER - OPT patterns Proof idea ◮ Reduction from propositional quantified SAT ◮ The pattern codifies a quantified formula ∀ x 1 ∃ x 2 ∀ x 3 · · · ϕ.

  42. Evaluation in general is PSPACE-complete. Theorem For general patterns that include OPT operator, the evaluation problem is PSPACE-complete. ◮ still PSPACE-complete for AND - FILTER - OPT patterns Proof idea ◮ Reduction from propositional quantified SAT ◮ The pattern codifies a quantified formula ∀ x 1 ∃ x 2 ∀ x 3 · · · ϕ. ◮ Using nested OPTs to codify quantifier alternations.

  43. Outline Motivation Our contributions Syntax and semantics of SPARQL graph patterns Syntax Semantics Complexity results Well–designed graph patterns Complexity Normalization and optimization

  44. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) if a variable occurs

  45. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ if a variable occurs inside B

  46. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ↑ ↑ if a variable occurs inside B and anywhere outside the OPT ,

  47. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑ if a variable occurs inside B and anywhere outside the OPT , then the variable must also occur inside A .

  48. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑ if a variable occurs inside B and anywhere outside the OPT , then the variable must also occur inside A . Example � � � � (? Y , name, paul) OPT (? X , email, ? Z ) AND (? X , name, john)

  49. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑ if a variable occurs inside B and anywhere outside the OPT , then the variable must also occur inside A . Example � � � � (? Y , name, paul) OPT (? X , email, ? Z ) AND (? X , name, john) ↑

  50. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑ if a variable occurs inside B and anywhere outside the OPT , then the variable must also occur inside A . Example � � � � (? Y , name, paul) OPT (? X , email, ? Z ) AND (? X , name, john) ↑ ↑

  51. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑ if a variable occurs inside B and anywhere outside the OPT , then the variable must also occur inside A . Example � � � � (? Y , name, paul) OPT (? X , email, ? Z ) AND (? X , name, john) � � ↑ ↑

  52. Well–designed patterns Definition An AND-FILTER-OPT pattern is well–designed iff for every OPT in the pattern ( · · · · · · · · · · · · ( A OPT B ) · · · · · · · · · · · · ) ↑ ⇑ ↑ ↑ if a variable occurs inside B and anywhere outside the OPT , then the variable must also occur inside A . Example � � � � (? Y , name, paul) OPT (? X , email, ? Z ) AND (? X , name, john) � � ↑ ↑ ◮ Well-designed patterns initially proposed to show equivalence with a procedural semantics (by W3C)

  53. Evaluation of well-designed patterns is in coNP-complete Theorem For AND - FILTER - OPT well–designed graph patterns the evaluation problem is coNP-complete

  54. Evaluation of well-designed patterns is in coNP-complete Theorem For AND - FILTER - OPT well–designed graph patterns the evaluation problem is coNP-complete Corollary For patterns of the form P 1 UNION P 2 UNION · · · UNION P k where every P i is a UNION -free well-designed pattern, the evaluation problem is coNP-complete

  55. Classical optimization is not directly applicable. ◮ Classical optimization assumes null–rejection.

  56. Classical optimization is not directly applicable. ◮ Classical optimization assumes null–rejection. ◮ null–rejection: the join/outer–join condition must fail in the presence of null.

  57. Classical optimization is not directly applicable. ◮ Classical optimization assumes null–rejection. ◮ null–rejection: the join/outer–join condition must fail in the presence of null. ◮ SPARQL operations are never null–rejecting ◮ by definition of compatible mappings.

  58. Classical optimization is not directly applicable. ◮ Classical optimization assumes null–rejection. ◮ null–rejection: the join/outer–join condition must fail in the presence of null. ◮ SPARQL operations are never null–rejecting ◮ by definition of compatible mappings. ◮ Can we use classical optimization in the context of SPARQL?

  59. Classical optimization is not directly applicable. ◮ Classical optimization assumes null–rejection. ◮ null–rejection: the join/outer–join condition must fail in the presence of null. ◮ SPARQL operations are never null–rejecting ◮ by definition of compatible mappings. ◮ Can we use classical optimization in the context of SPARQL? ◮ Well-designed patterns are suitable for reordering, and then for classical optimization.

  60. Well–designed graph patterns and optimization Consider the following rules: (( P 1 OPT P 2 ) FILTER R ) − → (( P 1 FILTER R ) OPT P 2 ) (1) ( P 1 AND ( P 2 OPT P 3 )) − → (( P 1 AND P 2 ) OPT P 3 ) (2) (( P 1 OPT P 2 ) AND P 3 ) − → (( P 1 AND P 3 ) OPT P 2 ) (3)

  61. Well–designed graph patterns and optimization Consider the following rules: (( P 1 OPT P 2 ) FILTER R ) − → (( P 1 FILTER R ) OPT P 2 ) (1) ( P 1 AND ( P 2 OPT P 3 )) − → (( P 1 AND P 2 ) OPT P 3 ) (2) (( P 1 OPT P 2 ) AND P 3 ) − → (( P 1 AND P 3 ) OPT P 2 ) (3) Proposition If P is a well-designed pattern and Q is obtained from P by applying either (1) or (2) or (3), then Q is a well-designed pattern equivalent to P .

  62. Well–designed graph patterns and optimization Definition A graph pattern P is in OPT normal form if there exist AND-FILTER patterns Q 1 , . . . , Q k such that: P is constructed from Q 1 , . . . , Q k by using only the OPT operator.

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