CSc 8710, Fall 2003
Practice Problems - Datalog Querying of Relational Database
------------------------------------------------------------

Consider the following relational database schema:

MOVIES(TITLE,Director)
ACTORS(TITLE,ACTOR)
THEATERS(TNAME,Address,Phone)
PLAYS(TNAME,TITLE,STARTTIME)

The key attributes are shown in all capital letters.
The MOVIES table records information about
current movies, the ACTORS table records information
about the different actors acting in each movie,
the THEATERS table records information
about the various theaters in a city and the PLAYS
table records information about which movie is being played in
which theater and at what time.

Write Datalog programs to answer the following queries.

(1) Find the directors who have acted in a movie they directed.

(2) Find the movies that are directed by Kurosawa or
    are being played in theater Odeon.

(3) Find the directors such that EVERY actor has acted
    in at least one of his or her movies.

(4) Find actors who act ONLY for director Kurosawa.

(5) Find all pairs of actors who act in EXACTLY the same movies.