天天看點

comp3311-assignment2輔導

文章目錄

  • ​​分析​​
  • ​​注意事項不要做​​
  • ​​建議​​
  • ​​測試​​
  • ​​Question​​
  • ​​準備前​​
  • ​​Q1​​
  • ​​Q2​​
  • ​​詳情​​
  • ​​vxdb$ python3 q2.py mothra Movies matching 'mothra'​​
  • ​​vxdb$: python3 q4.py rooney Names matching 'rooney'​​
  • ​​vxdb$ python3 q4.py 'spike lee' Filmography for Spike Lee (1957-)​​
  • ​​Personal Rating: 7.1 Top 3 Genres: drama comedy documentary​​
  • ​​People who directed most Movies (most)​​
  • ​​Alternative Releases (aliases) for a Movie (rels)​​
  • ​​vxdb$ python3 q2.py ocean Movies matching 'ocean'​​
  • ​​vxdb$ python3 q2.py dangerous Movies matching 'dangerous'​​
  • ​​vxdb$ python3 q2.py breakfast Movies matching 'breakfast'​​
  • ​​Movie Information (minfo)​​
  • ​​vxdb$ python3 q3.py 'Avatar' Avatar (2009)​​
  • ​​vxdb$ python3 q3.py 'The Ring' Movies matching 'The Ring'​​
  • ​​vxdb$ python3 q3.py '^The Ring$' 2002 The Ring (2002)​​
  • ​​vxdb$ python3 q3.py ': the return of the king' The Lord of the Rings: The Return of the King (2003)​​
  • ​​vxdb$ python3 q3.py 'strangelove' 1964 Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb (1964)​​
  • ​​vxdb$ python3 q3.py ring 2002 Movies matching 'ring' 2002​​
  • ​​Biography/Filmography for a Name (bio)​​
  • ​​vxdb$ python3 q4.py 'Rafal Zimowski' Filmography for Rafal Zimowski (1974-)​​
  • ​​Personal Rating: 7.3 Top 3 Genres: biography drama​​
  • ​​vxdb$ python3 q4.py belushi Names matching 'belushi'​​
  • ​​-- no movie is found vxdb$ python3 q4.py 'Gary Rosen' Filmography for Gary Rosen (???)​​
  • ​​Personal Rating: 0 Top 3 Genres:​​
  • ​​-- person is in the principal list but has no roles vxdb$ python3 q4.py 'nutan prasad' Filmography for Nutan Prasad (1945-2011)​​
  • ​​Personal Rating: 8.9 Top 3 Genres: comedy​​
  • ​​vxdb$ python3 q4.py belushi 1954 Filmography for Jim Belushi (1954-)​​
  • ​​Personal Rating: 6.4 Top 3 Genres: action comedy crime​​
  • ​​vxdb$ python3 q4.py 'spike lee' Filmography for Spike Lee (1957-)​​
  • ​​Personal Rating: 7.1 Top 3 Genres: drama comedy documentary​​

分析

注意事項不要做

  1. Note that hardcoding is strictly forbidden. :不要直接把答案輸出,而沒有結果

建議

  1. ~*:使用大小寫不敏感的正則符号
  2. crew role 中的production_manager,輸出的時候首字母大寫,并且下劃線改成空格
  3. 最後使用一些工具檢查一下代碼風格
  4. 運作時間每一個都不應該超過10s

測試

​./check​

Question

準備前

資料庫比ass1的資料庫簡單,可以首先,把這幾個資料庫中的内容都看一遍。

Q1

用到的表格,movies,names

Q2

詳情

COMP3311 22T1 Assignment 2

Python, Psycopg2 and IMDB Database Systems

Last updated: Sunday 27th March 4:15pm

Most recent changes are shown in red … older changes are shown in brown.

[Assignment Spec] [Database Design] [SQL Schema] [Testing] [Sample Outputs] [Fixes+Updates]

Aims

This assignment aims to give you practice in

manipulating a moderately large database (IMDB)

implementing SQL views to satisfy requests for information

implementing PLpgSQL functions to satisfy requests for information

implementing Python scripts to extract and display data

The goal is to build some useful data access operations on the Internet Movie Database (IMDB), which contains a wealth of information about movies, actors, etc. You need to write Python scripts, using the Psycopg2 database connectivity module, to extract and display information from this database.

Summary

Submission: Submit required files on moodle

Required Files: q1.py q2.py q3.py q4.py xtras.sql (not necessary)

Deadline: 21:00 Friday 15 April

Marks: 20 marks toward your total mark for this course

Late Penalty: 0.1 marks off the ceiling mark for each hour late, no submission is accepted 5 days (120h) after the deadline

How to do this assignment:

read this specification carefully and completely

create a directory for this assignment

unpack the supplied files into this directory

run your PostgreSQL server

set up the supplied database (must be called imdb)

complete the tasks below by editing the files

q1.py … Python script to list people who have directed the most movies

q2.py … Python script to show world releases for a Movie

q3.py … Python script to show cast+crew for a Movie

q4.py … Python script to show biography/filmography of a Name

xtras.sql … Put any helper views or plpgsql functions here. It is not necessary.

submit these files on moodle (you can submit multiple times)

If there exists xtras.sql in your submission, we will first load the file into the database by “psql imdb -f xtras.sql” and then test your python scripts. Details of the above steps are given below.

Introduction

The Internet Movie Database (IMDB) is a huge collection of information about all kinds of video media. It has data about most movies since the dawn of cinema, but also a vast amount of information about TV series, documentaries, short films, etc. Similarly, it holds information about the people who worked on and starred in these video artefacts. It also hold viewer ratings and crticis reviews for video artefacts as well as a host of other trivia (e.g. bloopers).

The full IMDB database is way too large to let you all build copies of it, so we have have created a cut-down version of the database that deals with well-rated movies from the last 60 years. You can find more details on the database schema in the [Database Design] page.

Some comments about the data in our copy of IMDB: there seems to be preponderance of recent Bollywood movies; some of the aliases look incorrect (e.g. for “Shawshank Redemption”); the data only goes to mid 2019, so you won’t find recent blockbusters.

Assignment Setup

Server Setup. This section describes how to carry out this assignment. Some of the instructions must be followed exactly; others require you to exercise some discretion. The initial instructions are targetted at people doing the assignment on d.cse. For the assignment setup on your home computer, you’ll need to adapt instructions in Local Setup.

The first step in setting up this assignment is to go to your directory and get templates of your python scripts for this assignment. Note that you can create a subfolder to store all assignment files if you like.

vxdb$ cd /localstorage/YourZid … go to your working directory

vxdb$ unzip /home/cs3311/web/22T1/assignments/ass2/ass2.zip … unzip all template files to your current directory

Archive: /home/cs3311/web/22T1/assignments/ass2/ass2.zip

inflating: q1.py

inflating: q2.py

inflating: q3.py

inflating: q4.py

inflating: xtras.sql

The second step is to load the database. Note that the database dump is quite large. Do not copy into your assignment directory on the CSE servers, because you only need to read it once to build your database (see below).

… login to d.cse and source env as usual …

vxdb$ dropdb imdb … if you already had such a database

vxdb$ createdb imdb

vxdb$ bzcat /home/cs3311/web/22T1/assignments/ass2/database/imdb.dump.bz2 | psql imdb

vxdb$ psql imdb

… examine the database contents …

Note the database contains non-ascii characters, and so you will need to make sure that your PostgreSQL server uses UTF8 encoding (and corresponding collation) before it will load.

Loading the database should take less than 10 seconds on d.cse, assuming that d.cse is not under heavy load. (If you leave your assignment until the last minute, loading the database on d.cse will be considerably slower, thus delaying your work even more. The solution: at least load the database Right Now, even if you don’t start using it for a while.) (Note that the imdb.dump file is 20MB in size; copying the compressed version under your CSE home directory or your localstorage/ directory is not a good idea).

If you have other large databases under your PostgreSQL server on d.cse or you have large files under your /localstorage/YOU/ directory, it is possible that you will exhaust your d.cse disk quota. In particular, you will not be able to store a copy of the MyMyUNSW database as well as the IMDB database under your d.cse server. The solution: remove any existing databases before loading your IMDB database. Using remote-ssh extension of VScode may also cause the disk quota issue. So stop using it.

Local Setup. Before downloading assignment files, your local machine should have installed PostgreSQL, Python3 and Psycopg2. All files required in the assignment are listed below. You can download them by clicking the file name.

ass2.zip … templates of python script

imdb.dump.bz2 … compressed database dump file.

Download ass2.zip and imdb.dump.bz2 to your home computer, unzip them, and perform commands analogous to the above. You should have a copy of the IMDB database that you can use at home to do this assignment. Think of some questions you could ask on the database and work out SQL queries to answer them. One useful query is

imdb=# select * from dbpop();

This will give you a list of tables and the number of tuples in each.

Your Tasks

Answer each of the following questions by writing a Python/Psycopg2 script. You can add any SQL views or PLpgSQL functions that are used in your Python scripts into the file xtras.sql. If you want to use any other Python modules, make sure that they are available on d.cse; your submitted code will be tested on d.cse using the Python installed there. You can change the indentation from the two-space indent in the templates. Note that hardcoding is strictly forbidden. Below are several tips to do the assignment.

Use PostgreSQL’s case-insensitive regular expression pattern matching operator (~*) for matching partial names and titles. If you do this, it has the added advantage that your command-line arguments can be in any case you like, and you can even put regular expression chars into them.

Some of the questions below require you to display crew roles. In the database, these are stored as all lower-case with underscores replacing spaces, e.g. “production_manager”. When these are displayed, the first letter should be capitalised and each underscore should be replaced by a space character.

Several questions require to sort items in the result. These can be achieved by the SQL keyword ORDER BY.

Below is an example to run your scripts:

vxdb$ python3 q1.py 5

Q1 (2 marks)

Complete the script called “q1.py” so that it prints a list of the top N people who have directed the most movies (default N = 10). The script takes a single command-line argument which specifies how many people should appear in the list. People should be ordered from largest to smallest by the number of movies he/she directed, and should be displayed as, e.g.

vxdb$ python3 q1.py 5

48 Woody Allen

40 Takashi Miike

39 Jean-Luc Godard

37 Claude Chabrol

36 Martin Scorsese

Within groups of people with the same number of movies, people should be ordered alphabetically by his/her name (Names.name). If the user supplies a number less than 1, print the following message and exit.

vxdb$ python3 q1.py 0

Usage: q1.py [N]

For more examples of how the script behaves, see [Sample Outputs].

Q2 (3 marks)

Complete the script called “q2.py” so that it prints a list of the different releases (different regions, different languages) for a movie. The script takes a single command-line argument which gives a part of a movie name (could be the entire name or a pattern). If no argument is given, print the following message and exit.

vxdb$ python3 q2.py

Usage: q2.py ‘PartialMovieTitle’

If there are no movies matching the supplied partial-name, then you should print a message to this effect and quit the program, e.g.

vxdb$ python3 q2.py xyzzy

No movie matching ‘xyzzy’

If the partial-name matches multiple movies, simply print a list of matching movies (rating, title, year of release), ordered by rating (highest to lowest), then year of release (earliest to latest) and then by title (alphabetical order), e.g.

vxdb$ python3 q2.py mothra Movies matching ‘mothra’

7.1 Godzilla, Mothra and King Ghidorah: Giant Monsters All-Out Attack (2001)

6.6 Mothra (1961)

6.5 Mothra vs. Godzilla (1964)

6.2 Godzilla and Mothra: The Battle for Earth (1992)

If the partial name matches exactly one movie, then print that movie’s title and year, and then print a list of all of the other releases (aliases) of the movie. If there are no aliases, print “Title (Year) has no alternative releases”. For each alias, show at least the title. If a region exists, add this, and if a language is specified, add it as well, e.g.,

vxdb$ python3 q2.py 2001

2001: A Space Odyssey (1968) was also released as

‘2001’ (region: XWW, language: en)

‘Two Thousand and One: A Space Odyssey’ (region: US)

‘2001: Odisea del espacio’ (region: UY)

‘2001: Een zwerftocht in de ruimte’ (region: NL)

Movie releases should be ordered accoring to the ordering attribute in the Aliases table.

If an alias has no region or language, then put the string in the extra_info field in the parentheses. If it has neither region, language or extra info, just print the local title (without parentheses).

Note that if there are two movies with exactly the same original title, you will not be able to view their releases, since the title alone does not distinguish them. We consider this problem in the next question. Such tests will not be covered in this question.

For more examples of how the script behaves, see [Sample Outputs].

Q3 (5 marks)

Complete the script called “q3.py” so that it prints a list of cast and crew for a movie. The script takes a command-line argument which gives a part of a movie name (could be the entire name or a pattern). It also takes an optional command-line argument, which is a year and can be used to distinguish movies with the same title (or, at least, titles which match the partial movie name).

vxdb$ python3 q3.py

Usage: q3.py ‘MovieTitlePattern’ [Year]

If there are no movies matching the supplied partial-name, then you should print a message to this effect and quit the program, e.g.,

vxdb$ python3 q3.py xyzzy

No movie matching ‘xyzzy’

If the partial-name matches multiple movies, simply print a list of matching movies, the same as in Q2. If you need to disambiguate, either use a larger partial-name or add a year to the command line. If a longer partial-name and year still doesn’t disambiguate, print a list of matching movies as above.

If the command-line arguments identify a single movie, then print the movie details (title and year), followed by a list of the principal actors and their roles, followed by a list of the principal crew members and their roles. The list of actors should be sorted according to the ordering attribute in the Principals table (i.e the biggest star comes first) and then by the name of the role they played if the ordering attribute is equal (i.e. one actor plays multiple roles). The list of crew members should also be sorted according to the ordering attribute in the Principals table and then by role name, if the ordering attribute is the same (e.g. one person has multiple crew roles).

Some movies are not in Principals table, they will not be tested. For more examples of how the script behaves, see [Sample Outputs].

Q4 (6 marks)

Complete the script called “q4.py” so that it prints a filmography for a given person (Names), showing their roles in each of the movies they have been a principal in. The script takes a command-line argument which gives a part of a person’s name (could be the entire name or a pattern). It also takes an optional command-line argument, which is a year (their birth year) and which can be used to distinguish people with similar names. If there are no arguments or there are invalid arguments, print the following message and exit.

vxdb$ python3 q4.py

Usage: q4.py ‘NamePattern’ [Year]

If the name pattern, optionally combined with a year, doesn’t match anyone in the Names table, then you should print a message to this effect and quit the program

vxdb$ python3 q4.py Smmith

No name matching ‘Smmith’

If the name pattern, optionally combined with a year, matches more than one person, then print a list of the matching people, with the years they were born and died in parentheses afer the name. If birth year is invalid, e.g., null, regardless of whether death year is valid or not, print (???); if birth year is valid but death year is invalid, print (bbbb-); if both are valid, print (bbbb-dddd). Below is an example.

vxdb$: python3 q4.py rooney Names matching ‘rooney’

Darrell Rooney (???)

Frank Rooney (1913-)

Jennie Rooney (???)

Mickey Rooney (1920-2014)

Nancy Rooney (???)

Rooney Mara (1985-)

Sharon Rooney (1988-)

Order people by their names alphabetically, then by birth year in chronological order. If two people have the same name and birth year, put them in order of their Names.id value (ascending).

If the name pattern, optionally combined with a year, matches a single person, then you should print their name and birth and death years (use the above rules), followed by two parts:

The first part

Two pieces of information, the first one gives their ‘personal rating’, that is the average rating of all movies they have been a principal in. Use AVG() function to calculate the average, convert the average to decimal, then use ROUND(avg,1) to one decimal place. If no movie is found, set the persoanl rating as 0; the second one gives top 3 movie genres of all movies they have been a principal in. The movie genres should be ordered by the number of such movies they have been a principal in, then the genre name (alphabetically). If there are less than 3 genres in total, just print all of them. If no genre, leave blank. (See examples)

The second part

A list of all the movies (with start years) they have been a principal in. Movies should be in chronological order; if there are multiple movies in a given year, order them by title within the year. For each movie, show first any acting roles they had, including the role they played, and then any production crew roles they had. If a movie has him/her in its principal list but no acting roles or crew roles can be found, only print the movie title and its start year. If no movie is found, leave blank. (See examples)

Note that one person could be both an actor and a director in the same movie. If a person has multiple roles as an actor in one movie, then show the records in order of the role name. Similarly for multiple roles as a crew member, order by role name.

vxdb$ python3 q4.py ‘spike lee’ Filmography for Spike Lee (1957-)

Personal Rating: 7.1 Top 3 Genres: drama comedy documentary

She’s Gotta Have It (1986)

playing Mars Blackmon – acting role

as Director – crew role

as Writer

School Daze (1988)

as Director

as Writer

Do the Right Thing (1989)

as Director

as Writer

Mo’ Better Blues (1990)

playing Giant

as Director

as Writer

… etc. etc. etc. …

For more examples of how the script behaves, see [Sample Outputs].

Style & Performance (2 marks)

Your programming style will be marked according to the following criteria

consistent indentation (somewhat forced by Python)

meaningful variable/function names

efficient use of the database (see details below)

There is a performance requirement in each task. Any solution that takes longer than 10 seconds on any of our test cases will be penalised for that case, even if it eventually produces the correct result.

Submission & Testing

We will test your submission as follows:

create a testing subdirectory containing your xtras.sql and Python scripts

create a new database imdb and initialise it with imdb.dump.bz2

run the command: psql imdb -f xtras.sql (if you provide xtras.sql)

load and run the tests in the check script. (Additional test cases will be used for marking)

Your submitted code must be complete so that when we do the above, your python scripts and xtras.sql will load without errors, which accounts for 2 marks out of 20. You should throgouhly test your scripts before you submit them. If your Python or SQL scripts generate load-time errors and/or have missing definitions, you will be penalised by a 2 mark administrative penalty.

An example for the test script is provided in [testing]. Before submission, it would be useful to test out whether the submitted files work by following a similar sequence of steps to those noted above.

COMP3311 22T1 Assignment 2

The IMDB Database Database Systems

Last updated: Saturday 26th March 7:21pm

Most recent changes are shown in red … older changes are shown in brown.

[Assignment Spec] [Database Design] [SQL Schema] [Testing] [Sample Outputs] [Fixes+Updates]

Introduction

This document contains a description of the data model for the IMDB database. Note that schema is simplified from the original downloadable data available on line, and contains substantially less data. We consider only movies that were made after 1959 and have a reasonable rating. The original data contains a variety of other media types (e.g. TV series) and considers movies from the late 1800’s onwards, even junk ones with low ratings.

Data Model and Schema

This section aims to give an overview of the data model. It concentrates mainly on the entities and their relationships.

Treat the ER data model description below as an overview, and consult the SQL Schema for full details. The SQL schema makes some deviations from the ER design:

entity names are singular here, but plural in the SQL schema

attribute names are often shortened in the SQL schema

the Aliases entity is given as a weak entity here,

but has its own id (i.e strong entity) in the SQL schema

To make the presentation clearer, the data model is presented in a number of sections.

“People”

Entities and relationships related to people and other entities who appear in movies.

Movies and Aliases

Entities and relationships linking people and the unit they work in …

Overview

All entities (without attributes) and relationships between them

COMP3311 22T1 Assignment 2

MyMyUNSW Schema Database Systems

Last updated: Sunday 20th March 11:26pm

Most recent changes are shown in red … older changes are shown in brown.

[Assignment Spec] [Database Design] [SQL Schema] [Testing] [Sample Outputs] [Fixes+Updates]

database/schema.sql

– COMP3311 22T1 Ass2 … schema for IMDB data

create domain Counter integer check (value >= 0);

– these are ideal domain definitions

– create domain Minutes integer check (value > 0);

– create domain YearType integer check (value > 1800);

– unfortunately, the data in IMDB doesn’t agree

– so we use these instead

create domain Minutes integer check (value >= 0);

create domain YearType integer check (value >= 0);

create table Movies (

id integer,

title text not null,

orig_title text,

start_year YearType not null,

end_year YearType,

runtime Minutes,

rating float,

nvotes Counter,

primary key (id)

);

create table Movie_genres (

movie_id integer, – not null because PK

genre text, – not null because PK

foreign key (movie_id) references Movies(id),

primary key (movie_id, genre)

);

create table Aliases (

id integer,

movie_id integer not null,

ordering Counter not null,

local_title text not null,

region char(4),

language char(4),

extra_info text,

foreign key (movie_id) references Movies(id),

primary key (id)

);

create table Names (

id integer,

name text not null,

birth_year YearType, – ideally, not null

death_year YearType,

primary key (id)

);

create table Principals (

movie_id integer, – not null because PK

ordering Counter, – not null because PK

name_id integer not null,

foreign key (movie_id) references Movies(id),

foreign key (name_id) references Names(id),

primary key (movie_id, ordering)

);

create table Acting_roles (

movie_id integer, – not null because PK

name_id integer, – not null because PK

played text, – not null because PK

foreign key (movie_id) references Movies(id),

foreign key (name_id) references Names(id),

primary key (movie_id,name_id,played)

);

create table Crew_roles (

movie_id integer, – not null because PK

name_id integer, – not null because PK

role text, – not null because PK

foreign key (movie_id) references Movies(id),

foreign key (name_id) references Names(id),

primary key (movie_id,name_id,role)

);

COMP3311 22T1 Assignment 2

Testing Database Systems

Last updated: Monday 28th March 11:30pm

Most recent changes are shown in red … older changes are shown in brown.

[Assignment Spec] [Database Design] [SQL Schema] [Testing] [Sample Outputs] [Fixes+Updates]

A shell script is available to assist with testing:

/home/cs3311/web/22T1/assignments/ass2/check

Note that the check script can only be used on Linux platforms. For Windows local users, you can run each test case and compare the results manually on your local machine. Then upload your codes and run the check script on d.cse server.

First, get test cases (tests.zip for both Linux and MacOS) and the check script (check for Linux or check for MacOS) into your working directory. Extract test cases from the zip file. Keep them in the tests folder. Below is the commands on the server. Download the files to your home machine by clicking the file names above.

vxdb$ cd /localstorage/YourZid

vxdb$ cp /home/cs3311/web/22T1/assignments/ass2/check .

vxdb$ cp /home/cs3311/web/22T1/assignments/ass2/tests.zip .

vxdb$ unzip tests.zip -d tests

Archive: tests.zip

inflating: tests/01.expected

extracting: tests/02.expected

inflating: tests/03.expected

extracting: tests/04.expected

extracting: tests/05.expected

Put all your Python scripts in the same directory of check. If you list all files and directories in your working directory. You should at least have: check script, your python scripts q1.py, q2.py, q3.py, q4.py, and tests/ folder which includes all test cases.

vxdb$ ls

check q1.py q2.py q3.py q4.py xtras.sql tests tests.zip

Next, load the IMDB database if you don’t have one or if you want a fresh copy.

… login to d.cse and source env as usual …

vxdb$ dropdb imdb … if you already had such a database

vxdb$ createdb imdb

vxdb$ bzcat /home/cs3311/web/22T1/assignments/ass2/database/imdb.dump.bz2 | psql imdb

Load xtras.sql if you defined any view or function.

vxdb$ psql imdb -f xtras.sql

Now you can run check script to check your outputs and running times. This may take a while, especially if some of your queries are slow.

vxdb$ ./check

Test 01 PASSED (.18s)

Test 02 PASSED (.20s)

Test 03 PASSED (.18s)

Test 04 PASSED (.05s)

Test 05 PASSED (.05s)

Test 06 PASSED (.25s)

Test 07 PASSED (.05s)

Test 08 PASSED (.12s)

Cases 1–6 test q1.sql. Cases 7–15 test q2.sql. Cases 16–25 test q3.sql. Cases 26–39 test q4.sql. See the tests/tests script file for details of each case. If your output has the same records to the expected one but in an incorrect order, or your output is incorrect, you may get the following messages:

vxdb$ ./check

Test 01 Different order (.18s)

Check differences using ‘diff tests/01.observed tests/01.expected’

Test 10 FAILED (.20s)

Check differences using ‘diff tests/10.observed tests/10.expected’

If you have errors, you can always look at the expected results and compare them manually to your results. If you think that any of our expected results are incorrect, let us know and we can make a new version of check that you can reload.

COMP3311 22T1 Assignment 2

Sample Outputs Database Systems

Last updated: Saturday 26th March 5:31pm

Most recent changes are shown in red … older changes are shown in brown.

[Assignment Spec] [Database Design] [SQL Schema] [Testing] [Sample Outputs] [Fixes+Updates]

The following give some sample inputs and outputs that you can use to estimate the correctness of your scripts These examples are by no means exhaustive, and more cases will be used in the auto-marking, so it is up to you to perform comprehensive checking of your solution.

Warning: sometimes, non-ascii characters don’t render the same on this web page as they do in a terminal window.

People who directed most Movies (most)

vxdb$ python3 q1.py xyz

Usage: q1.py [N]

vxdb$ python3 q1.py

48 Woody Allen

40 Takashi Miike

39 Jean-Luc Godard

37 Claude Chabrol

36 Martin Scorsese

35 Johnnie To

34 Clint Eastwood

34 Werner Herzog

31 Kartal Tibet

31 Steven Spielberg

vxdb$ python3 q1.py 20

48 Woody Allen

40 Takashi Miike

39 Jean-Luc Godard

37 Claude Chabrol

36 Martin Scorsese

35 Johnnie To

34 Clint Eastwood

34 Werner Herzog

31 Kartal Tibet

31 Steven Spielberg

30 Priyadarshan

29 Ingmar Bergman

29 Satyajit Ray

29 Sidney Lumet

28 John Huston

28 Steven Soderbergh

26 Hark Tsui

26 John Sturges

26 Ken Loach

26 Luis Buñuel

vxdb$ python3 q1.py 5

48 Woody Allen

40 Takashi Miike

39 Jean-Luc Godard

37 Claude Chabrol

36 Martin Scorsese

vxdb$ python3 q1.py 0

Usage: q1.py [N]

vxdb$ python3 q1.py 1

48 Woody Allen

Alternative Releases (aliases) for a Movie (rels)

vxdb$ python3 q2.py

Usage: q2.py ‘PartialMovieTitle’

vxdb$ python3 q2.py 1999

No movie matching ‘1999’

vxdb$ python3 q2.py ocean Movies matching ‘ocean’

8.0 A Plastic Ocean (2016)

7.9 Planet Ocean (2012)

7.8 Ocean’s Eleven (2001)

7.8 Oceans (2009)

7.6 Ocean Heaven (2010)

7.2 The Light Between Oceans (2016)

7.0 711 Ocean Drive (1950)

6.9 Ocean’s Thirteen (2007)

6.6 Ocean’s 11 (1960)

6.5 Ocean’s Twelve (2004)

6.4 The Deep End of the Ocean (1999)

6.2 Ocean’s Eight (2018)

vxdb$ python3 q2.py dangerous Movies matching ‘dangerous’

7.7 The Most Dangerous Man in America: Daniel Ellsberg and the Pentagon Papers (2009)

7.6 Dangerous Liaisons (1988)

7.5 Dangerous Encounters of the First Kind (1980)

7.3 On Dangerous Ground (1951)

7.3 Dangerous Beauty (1998)

7.2 Living Dangerously (1987)

7.1 Dangerous Crossing (1953)

7.1 The Year of Living Dangerously (1982)

7.1 Young and Dangerous (1996)

7.0 Confessions of a Dangerous Mind (2002)

7.0 The Dangerous Lives of Altar Boys (2002)

6.7 Young and Dangerous 2 (1996)

6.7 Young and Dangerous 3 (1996)

6.7 Gringo: The Dangerous Life of John McAfee (2016)

6.6 Dangerous Moves (1984)

6.6 Bangkok Dangerous (2000)

6.6 Dangerous Parking (2007)

6.5 Johnny Dangerously (1984)

6.5 Dangerous Minds (1995)

6.4 Young and Dangerous 1997 (1997)

6.4 A Dangerous Method (2011)

6.2 Dangerous When Wet (1953)

6.1 Young and Dangerous 1998 (1998)

6.1 Cute & Dangerous (2015)

vxdb$ python3 q2.py breakfast Movies matching ‘breakfast’

7.9 The Breakfast Club (1985)

7.7 Breakfast at Tiffany’s (1961)

7.7 Breakfast with Hunter (2003)

7.5 Rooster’s Breakfast (2007)

7.2 Breakfast on Pluto (2005)

6.8 A Dog’s Breakfast (2007)

6.8 Breakfast with Scot (2007)

vxdb$ python3 q2.py “Ocean’s Eleven”

Ocean’s Eleven (2001) was also released as

‘11’ (region: US)

‘O11’ (region: US)

‘Ocean’s 11’ (region: US)

‘I symmoria ton enteka’ (region: GR)

‘La gran estafa’ (region: UY)

vxdb$ python3 q2.py ‘Ne Zha’

Ne Zha (2019) was also released as

‘Nezha’ (region: XWW, language: en)

‘Nezha: Birth of the Demon Child’ (region: XWW, language: en)

‘Nezha’ (region: HK, language: en)

‘Nezha’ (region: XAS, language: en)

‘Naazaa’ (region: CN, language: yue)

‘Nezha’ (region: XAS, language: cmn)

‘Nezha’ (region: US)

‘Nezha’ (region: CA, language: en)

‘Nezha’ (region: MY, language: cmn)

‘Nezha’ (region: TW)

‘Nezha’ (region: HK, language: cmn)

‘Nezha’ (region: SG, language: cmn)

‘Naazaa’ (region: HK, language: yue)

‘Nezha’ (region: CN, language: cmn)

‘Birth of the Demon Child Nezha’ (region: XWW, language: en)

vxdb$ python3 q2.py ‘You Are the Apple of My Eye’

You Are the Apple of My Eye (2011) has no alternative releases

vxdb$ python3 q2.py ‘Dragon Ball Z: Super Android 13’

Dragon Ball Z: Super Android 13 (1992) was also released as

‘Dragon Ball Z: Super Android 13’ (new title)

‘Dragon Ball Z: Super Android 13’ (region: US)

‘Dragon Ball Z Movie: Super Battle of 3 Super Saiyas’ (region: MY, language: en)

‘Dragon Ball Z: Kyokugen Battle!! Sandai Super Saiyajin’ (region: JP)

‘Dragon Ball Z 7: Battle Limit!! Three Great Super Saiyans’ (literal english title)

‘Dragon Ball Z: O Retorno dos Andróides’ (region: BR)

‘Dragon Ball Z: Super Battle of Three Super Saiyas’ (region: MY, language: en)

‘Zmajeva kugla Z: Tri super Saiyana’ (region: HR)

Movie Information (minfo)

vxdb$ python3 q3.py

Usage: q3.py ‘MovieTitlePattern’ [Year]

vxdb$ python3 q3.py xyzzy

No movie matching ‘xyzzy’

vxdb$ python3 q3.py ‘Avatar’ Avatar (2009)

Starring

Sam Worthington as Jake Sully

Zoe Saldana as Neytiri

Sigourney Weaver as Dr. Grace Augustine

Michelle Rodriguez as Trudy Chacón

and with

James Cameron: Director

James Cameron: Writer

Jon Landau: Producer

James Horner: Composer

Mauro Fiore: Cinematographer

John Refoua: Editor

Stephen E. Rivkin: Editor

vxdb$ python3 q3.py ‘The Ring’ Movies matching ‘The Ring’

8.9 The Lord of the Rings: The Return of the King (2003)

8.8 The Lord of the Rings: The Fellowship of the Ring (2001)

8.7 The Lord of the Rings: The Two Towers (2002)

7.1 The Ring (2002)

6.6 The Ring-necked Dove (1970)

6.5 Closing the Ring (2007)

6.3 Again the Ringer (1965)

6.2 The Ring (1952)

6.2 The Lord of the Rings (1978)

6.2 The Ring Finger (2005)

vxdb$ python3 q3.py ‘^The Ring$’ 2002 The Ring (2002)

Starring

Naomi Watts as Rachel

Martin Henderson as Noah

Brian Cox as Richard Morgan

David Dorfman as Aidan

and with

Gore Verbinski: Director

Ehren Kruger: Writer

Kôji Suzuki: Writer

Hiroshi Takahashi: Writer

Laurie MacDonald: Producer

Walter F. Parkes: Producer

vxdb$ python3 q3.py ‘: the return of the king’ The Lord of the Rings: The Return of the King (2003)

Starring

Elijah Wood as Frodo

Viggo Mortensen as Aragorn

Ian McKellen as Gandalf

Orlando Bloom as Legolas

and with

Peter Jackson: Director

Peter Jackson: Writer

J.R.R. Tolkien: Writer

Fran Walsh: Writer

Philippa Boyens: Writer

Barrie M. Osborne: Producer

Howard Shore: Composer

vxdb$ python3 q3.py ‘strangelove’ 1964 Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb (1964)

Starring

Peter Sellers as Dr. Strangelove

Peter Sellers as Group Capt. Lionel Mandrake

Peter Sellers as President Merkin Muffley

George C. Scott as Gen. ‘Buck’ Turgidson

Sterling Hayden as Brig. Gen. Jack D. Ripper

Keenan Wynn as Col. ‘Bat’ Guano

and with

Stanley Kubrick: Director

Stanley Kubrick: Writer

Terry Southern: Writer

Peter George: Writer

Laurie Johnson: Composer

Gilbert Taylor: Cinematographer

Anthony Harvey: Editor

vxdb$ python3 q3.py ‘stars’ xyzzy

Usage: q3.py ‘MovieTitlePattern’ [Year]

vxdb$ python3 q3.py ‘return of the king’ 1234

No movie matching ‘return of the king’ 1234

vxdb$ python3 q3.py ring 2002 Movies matching ‘ring’ 2002

8.7 The Lord of the Rings: The Two Towers (2002)

7.3 On the Occasion of Remembering the Turning Gate (2002)

7.1 The Ring (2002)

6.9 Springtime in a Small Town (2002)

6.5 Ringeraja (2002)

Biography/Filmography for a Name (bio)

vxdb$ python3 q4.py

Usage: q4.py ‘NamePattern’ [Year]

vxdb$ python3 q4.py xyzzy

No name matching ‘xyzzy’

vxdb$ python3 q4.py ‘Rafal Zimowski’ Filmography for Rafal Zimowski (1974-)

Personal Rating: 7.3 Top 3 Genres: biography drama

300 Miles to Heaven (1989)

playing Jedrek

vxdb$ python3 q4.py belushi Names matching ‘belushi’

Jim Belushi (1954-)

John Belushi (1949-1982)

– no movie is found vxdb$ python3 q4.py ‘Gary Rosen’ Filmography for Gary Rosen (???)

Personal Rating: 0 Top 3 Genres:

– person is in the principal list but has no roles vxdb$ python3 q4.py ‘nutan prasad’ Filmography for Nutan Prasad (1945-2011)

Personal Rating: 8.9 Top 3 Genres: comedy

Aha Naa Pellanta (1987)

vxdb$ python3 q4.py belushi 1954 Filmography for Jim Belushi (1954-)

Personal Rating: 6.4 Top 3 Genres: action comedy crime

vxdb$ python3 q4.py ‘spike lee’ Filmography for Spike Lee (1957-)

Personal Rating: 7.1 Top 3 Genres: drama comedy documentary