exercise 4 conjunctive queries csp and hypergraphs
play

Exercise 4: Conjunctive Queries, CSP, and Hypergraphs Database - PowerPoint PPT Presentation

Exercise 4: Conjunctive Queries, CSP, and Hypergraphs Database Theory 2020-05-04 Maximilian Marx, David Carral 1 / 55 Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO


  1. Exercise 4: Conjunctive Queries, CSP, and Hypergraphs Database Theory 2020-05-04 Maximilian Marx, David Carral 1 / 55

  2. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) 2 / 55

  3. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. 3 / 55

  4. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. 4 / 55

  5. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. y x z v 5 / 55

  6. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. y x z (1) delete � x , y � v 6 / 55

  7. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. y x z (1) delete � x , y � (1) delete � y , z � v 7 / 55

  8. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. y x z (1) delete � x , y � (1) delete � y , z � v (1) delete � z , v � 8 / 55

  9. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. y x z (1) delete � x , y � (2) delete x (1) delete � y , z � v (1) delete � z , v � 9 / 55

  10. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. y z (1) delete � x , y � (2) delete x (1) delete � y , z � (2) delete y , z , v v (1) delete � z , v � 10 / 55

  11. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. (1) delete � x , y � (2) delete x (1) delete � y , z � (2) delete y , z , v (1) delete � z , v � � query is acyclic. 11 / 55

  12. Exercise 1 Exercise. Decide if the following conjunctive queries are tree queries by applying (one version of) the GYO algorithm. 1. ∃ x , y , z , v . r ( x , y ) ∧ r ( y , z ) ∧ r ( z , v ) ∧ s ( x , y , z ) ∧ s ( y , z , v ) 2. ∃ x , y , z , u , v , w . r ( x , y ) ∧ s ( x , z , v ) ∧ r ( u , z ) ∧ t ( x , v , u , w ) Definition (Lecture 6, Slides 24) A GYO-reduction is a procedure to check acyclicity: ◮ Input: hypergraph H = � V , E � (we do not need relation labels here) ◮ Output: GYO-reduct of H Apply the following simplification rules as long as possible: (1) Delete all hyperedges that are empty or that are contained in other hyperedges. (2) Delete all vertices that occur in at most one hyperedge. The input query is a tree query if the GYO-reduct of its hypergraph is the empty hypergraph. Solution. (1) delete � x , y � (2) delete x (1) delete � y , z � (2) delete y , z , v (1) delete � z , v � 12 / 55

Recommend


More recommend