COMP3311 Final Exam 20T3 The University of New South Wales
COMP3311 Database Systems
Final Exam 20T3
Database Systems
[Front Page] [Notes] [Database] [Course Website] [Cheat Sheets]
[Q1] [Q2] [Q3] [Q4] [Q5] [Q6] [Q7] [Q8] [Q9] [Q10] [Q11] [Q12]

Question 7 (11 marks)

Write a Python/Psycopg2 script that, given an album ID, produces a list of songs giving the song title, the people who performed on that song, and the instrument(s) they played on that song. Before the song details, it prints the title of the album, the year it was made, and the genre, followed by a line with 40 '=' characters.

Use the following ordering:

If nobody is mentioned as playing on the song, assume that everyone played and write "The whole group".

If the supplied album ID is invalid, the script should print an error message (see below) and terminate.

The examples below show the expected output format:

$ ./q7
Usage: ./q7 AlbumID
$ ./q7 999
Invalid album ID
$ ./q7 123
Up to this Night (2008) (blues)
========================================
 1. Fly to this Night
        Angus Serious: rythm guitar
        Steve Ward: mandolin,saxophone
 2. Master of the Sea
        Bernie Jaeger: acoustic guitar,guitars
        Ricky Malone: keyboard
 3. Where is Dancing
        Bernie Jaeger: vocals
        Ricky Malone: vocals
        Sam Plant: drums,mandolin
 4. What happened to this Night
        Bernie Jaeger: flute,keyboard
        Elton Smith: vocals
        Steve Ward: vocals
 5. Kill for Plague
        The whole group
 6. Force the Heat
        Elton Smith: vocals
        Sam Plant: vocals
 7. Shock Tokyo
        Steve Ward: vocals

Note that each song and the lines for each performer are printed as if by C statements like:

printf("%2d. %s\n", trackno, title)
printf('%8s%s: %s\n", ' ', name, instruments)

There are more examples in the tests/*.sh and tests/*.expected files.

Instructions:

Note: if the script won't execute properly as ./q7, try python3 ./q7 or whatever name the appropriate Python interpreter has in your environment.

End of Question