Introduction To Prolog
The Movie Database
Download the database for this task by clicking DOWNLOAD.
How The Facts Are Stated
The bold text in the four examples below indicates the format of the facts in the movies database.
movie(M,Y) = movie M came out in year Y
director(M,D) = movie M was directed by director D
actor(M,A,R) = actor A played role R in movie M
actor(american_beauty, kevin_spacey, lester_burnham).
actress(M,A,R) = actress A played role R in movie M
actress(american_beauty, annette_bening, carolyn_burnham).
Write queries to answer the following questions. Remember to press the semi-colon after each result until all the possible answers are revealed.
- In which year was the movie American Beauty released?
- Find the movies released in the year 2000.
- Find the movies released before 2000. ( eg movie(X, Y), Y<2000. )
- Find the movies released after 1990.
- Find an actor who has appeared in more than one movie. (2 queries with the same variable for actor, different for movie and role. You must also state that the first movie variable cannot equal the second).
- Find a director who has directed a movie in which the actress Scarlett Johansson appeared.
- Find an actor who has also directed a movie.
- Find an actor or actress who has also directed a movie.(Use the semi-colon to separate out the two queries, actors will be found first)
- Find the movie in which John Goodman and Jeff Bridges were co-stars.
- Find the movies in which Steve Buscemi and John Goodman were both actors.
Add rules to the database to do the following,
- released_after(M, Y) - the movie was released after the given yeaar
- released_before(M, Y) - the movie was released before the given year
- same_year(M1, M2) - the movies are released in the same year
- co_star(A1, A2) - the actor/actress are in the same movie