CS345 Assignment #3

Due Monday, April 26, 1999

Problem Set

  1. (20 pts.) Find the modularly stratified model for the following program and EDB: p(X) :- q(X) & r(X,Y) & NOT p(Y) q(X) :- r(X,Y) & NOT q(Y) q(X) :- a(X,Y) & a(Y,X) r(X,Y) :- a(X,Y) & b(X,Y) with EDB facts a(1,2), a(2,3), a(3,1), a(3,4), a(4,3), b(1,2), and b(2,3). Indicate the locally stratified model for each module.


  2. (20 pts.) Consider the conjunctive queries Q1 and Q2. Q1: p(U,Z) :- q(U,V) & q(X,Y) & r(Y,Z) & r(V,X) Q2: p(U,V) :- q(Y,U) & q(U,X) & r(U,V) & r(X,Y) Is Q1 contained in Q2? Is Q2 contained in Q1? Justify your answers by offering containment mappings or showing that none exists.


  3. (20 pts.) Consider the conjunctive queries Q1 and Q2. Q1: p(X) :- q(X,Y) & q(Y,Z) & q(Z,X) Q2: p(X) :- q(X,Y) & q(Y,Z) & q(Z,U) & q(U,V) Is Q1 contained in Q2? Is Q2 contained in Q1? Justify your answers by using the method of canonical databases.


  4. (20 pts.) Consider the conjunctive queries Q1 and Q2. Q1: p(X) :- q(X,Y) & q(Y,X) & r(X,U,Y) & r(Y,X,Z) & s(X,V) Q2: p(X) :- q(X,Y) & q(Y,Z) & r(X,Y,T) & r(U,V,T) Test whether Q1 is contained in Q2 by using Saraiya's containment test. Start by mapping q(X,Y) to q(X,Y). Indicate at each step what inferences are made.


  5. (20 pts.) Find all equivalences and containments among the four conjunctive queries below. Note that c is a constant in Q3. Q1: p(X,X) :- q(X,A) & q(A,Z) Q2: p(X,Y) :- q(X,A) & q(A,B) & q(B,C) & q(C,Y) Q3: p(X,Y) :- q(X,A) & q(A,c) & q(c,B) & q(B,Y) Q4: p(X,Y) :- q(X,A) & q(A,C) & q(B,C) & q(C,E) & q(C,D) & q(E,Y)