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 6 (10 marks)

Write Python/Psycopg2 script that, given a group ID, produces a discography for that group. The discography consists of an initial line that gives the names of the group, and then one entry for each album. For each album, it prints the list of songs and the length of each song in minutes:seconds format.

It uses the following ordering:

Note that you should use the trackno value from the database as the displayed track number, as well as using it for ordering.

Edge cases like a group with no albums and and an album with no songs will not be tested, so you can write whatever you like for those cases.

The examples below show the expected output format:

$ ./q6
Usage: ./q6 GroupID
$ ./q6 999
Invalid group ID
$ ./q6 5
Discography for Roaring Gang
--------------------
Waiting for Home (2010) (rock)
--------------------
 1. Dreams of Defeat (5:01)
 2. Fast Train to Tokyo (9:40)
 3. Kill for Summer (1:11)
 4. Feel Life (5:14)
 5. Take the Clouds (6:03)
 6. Up to Haze (1:55)
 7. Fast Train to the Heat (4:48)
 8. Fly to this World (4:37)
 9. Beyond White (5:40)
10. Feel Khatmandu (1:28)
--------------------
Up to Triumph (2011) (rock)
--------------------
 1. Escape from the Horizon (3:29)
 2. Pump up Haze (3:20)
 3. Master of this World (8:13)
... etc etc etc ...

Each album is introduced by its title, the year it was made, and its genre (see above), surrounded by two lines of 20 '-' characters. Each song is displayed as if printed by the C statement:

printf("%2d. %s (%d:%02d)\n", trackno, title, minutes, seconds)

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

Instructions:

End of Question