In this assignment, you will query a database of movies, actors/actresses, and directors. This data is a subset of the Internet Movie Database and is used in compliance with their terms and conditions.
To load this database into PostgreSQL:
pgAdmin
by clicking on Databases
in the left pane, and then selecting Edit -> New Object -> New Database...
from the top menu. Name the new database imdb
.imdb
in the list of databases in the left pane of pgAdmin. Click on it, and then select Tools -> Restore...
from the top menu. Find the file imdb.backup
and restore it.You should now have four tables in the the imdb
database: cast_info
, movies
, people
, and role_type
.
The movies
table contains information about some 1600 Hollywood movies. All feature-length movies up until late 2013 with at least 50,000 ratings on IMDB.com are included. The title, production year, rating, and number of votes are included in this table.
The people
table contains information about all of the actors, actresses and directors that appeared in the movies in the movies
table. The names and gender of these people are included.
The role_type
table is a small lookup table that relates role_id
s to role
s. This subset of the IMDB database contains only actors, actresses, and directors.
The cast_info
table is a lookup table that relates people to the roles they played in certain movies. Each row in the cast_info
table is an assignment of one person to one role in one movie. Obviously, a single person can play multiple roles in a single movie, or perform in many movies.
Use the imdb
database to answer the following questions.
List the titles of all of the movies (movies
table).
List the titles of all movies produced in 2012.
List the titles and ratings of all movies produced in 2012, and sort them in descending order by rating.
List the titles of all movies produced in either 1992 or 2012.
List the titles and ratings of all movies with ratings between 8.1 and 8.3.
Using table people
, list all those whose names contain ‘ford’.
Get the distinct role types of roles in the cast_info
table.
List of the movies with at least 500,000 votes.
Find the movie with the best overall rating.
Write a REGEX statement to find any name in table people
with “ford,” where “ford” can be upper or lower case.