# CS345 Assignment #6

### Problem Set

1. (30 pts.) In the following problem you are given some views with binding patterns, and you are asked to develop a Datalog program that answers a query using those views properly (i.e., with bindings for each argument that needs to be bound). You may apply the methodology outlined in class or any other appropriate methodology, but in the latter case, justify what you are doing.

The global predicates are:

• ep(E,P) = employee E has phone P.

• eo(E,O) = employee E has office O.

• ed(E,D) = employee E has department D.

• dm(D,M) = department D has manager M.

The views are:

• v1^bf(E,P) :- ep(E,P).

• v2^bf(E,O) :- eo(E,O).

• v3^fb(E,D) :- ed(E,D).

• v4^ff(D,M) :- dm(D,M).

The query is: ans(P,O) :- ep(E,P) & eo(E,O).

a)
Write the inverse rules for the views.

b)
Assuming that each of phone, office, and department are in domains by themselves, but employees and managers are the same domain, write a Datalog program that finds all possible answers to the query. You may follow the recipe given in class, where you write rules for the domains from the global predicates (which now stand for their own discoverable parts), rules that use the inverse rules from (a) with domain subgoals to represent proper bindings, and a rule to synthesize the answer from the discoverable portions of ep and eo. It is also acceptable to follow some other methodology that you explain.

c)
Is your program recursive? If it looks recursive, can you simplify it so the recursion disappears? If so, do it.

2. (20 pts.) Below are descriptions of ``typical'' students, faculty, and departments:

• Students have a student ID number, a name, a major department, a degree, and an advisor.

• Faculty members have a name, a department, an office, and a set of advisees.

• Departments have a name and a list of faculty members.

Show how typical student, faculty, and department objects could be represented in OEM. Draw at least one example of links between each pair of object types, if that link is meaningful.

3. (20 pts.) Suppose have we the following four sources that contain information about books:

• Source 1 produces information about authors and titles. (who wrote what book)

• Source 2 produces information about libraries, titles and authors. (what books a library has, and the author(s) for the books)

• Source 3 produces information about libraries, addresses and titles. (where libraries are located, and what books they carry)

• Source 4 produces information about bookstores and titles. (what books each bookstore carries)

You may assume that books with the same title are the same book. Write MSL rules for a mediator that uses these sources and exports the following objects:

a)
Objects that provide the author and title for a book.

b)
Objects that give the libraries and bookstores where a book can be found.

c)
Objects that provide information about libraries, their addresses, the titles they carry, and the authors for those books.

d)
Objects that have information about bookstores and the authors they carry.

4. (30 pts.) Suppose we have the following sources:

• v1(A,F,O,D) - Airline A has flight F from city O (origin) to city D (destination).

• v2(A,F,P,S) - Airline A has flight F with passengers P sitting in seat S.

• v3(P,L,T) - P is the name of a passenger, who has address L (location) and telephone number T.

The mediator exports the following objects:

• flight(F,O,D,P,S) :- v1(A,F,O,D) & v2(A,F,P,S)

• passenger(P,L,T) :- v3(P,L,T)

• airline(A,F) :- v1(A,F,O,D)
airline(A,F) :- v2(A,F,P,S)

a)
Write Tsimmis-style queries (following the Datalog-based simplification of MSL that we introduced in class) for the following:

• Which passengers are on flight UA775?

• Which flight is Mike Smith on, and what is his telephone number and address?

• Which airlines have flights from New York to Chicago?

b)
What are the IM solutions to the above queries, and how do they compare to the Tsimmis solutions?