# Homework 2

## Due January 27 at beginning of class

The goal of this assignment is to give you some more practice on trying for containment and answering queries using views to help you read the second paper for the 25th (Information Integration Using Logical Views). My suggestion is that you do the homework at the same time as you're reading the paper because this will help you to understand the other sections better, but this is entirely your choice.

In all cases, show the canonical databases needed to prove or disprove the hypothesis. Please be very careful about directionality, both in terms of what you're proving and in terms of what's being frozen and queried where; it's very easy to screw that up. Also please note that "contains" is the inverse of "e;is contained in"e;...

Questions 1-5 are worth 19% each, and question 5 is worth 5%.

1. (For Section 1.1)

Q1: p(X,Y):-r(X,Z) & g(Z,Z) & r(Z,Y)
Q2: p(A,B):-r(A,C) & g(C,D) & r(D,B)

Does Q2 contain Q1? Why or why not?

2. (For Section 1.2)

Q1: p(X,Y) :- a(X,Z) & a(Z,Y) & NOT a(X,Y)
Q2: p(X,Y) :- a(X,Y) & NOT a(Y,X)

Does Q2 contain Q1? Why or why not?

3. (For Section 1.3)

Q1: p(X,Y) :- q(X,Y) & r(U,V) & r(V,U)
Q2: p(X,Y) :- q(X,Y) & r(U,V) & U <= V

Does Q2 contain Q1? Why or why not?

4. (For Section 1.4)

Q: p(X,Y) :- a(X,Z) & a(Z,W) & a(W,Y)
P: p(X,Y) :- a(X,Y)
p(X,Y) :- p(X,Z) & p(Z,Y)

Does P contain Q? Why or why not?

5. (For Section 2.1)

Given query q and views v1 and v2:

q(X):-e1(X,Y),e2(Y,Z),e3(Z,X)

v1(A,B,C,D):-e1(A,B),e2(C,D)
v2(D,E):-e3(D,E)

Use v1 and v2 to create an equivalent query to q that does not access e1, e2, or e3. There is no need to show that they are equivalent.

Bonus thought experiment (no need to turn this in for credit): if the definition of V1 was v1(a,d), could you create an equivalent query for q using only v1 and v2? Why or why not?

1. How long did it take you to complete this assignment?
4. What helped you learn the best in this assignment?
5. What distracted from your learning in this assignment?