Query to retrieve tracklist for a release

I just started exploring the database schema underlying MusicBrainz, so this might be a trivial question with a simple answer.
Search results such as


show the tracklist for a given release. I have a hard time figuring out the SQL query underlying the connection between a release and tracks on a given release. I looked at various tables but have not been able to discover the respective link structure for formulating the SQL query. Any hints on what specific table(s) (attributes) manage such relationships are very much appreciated.

Thanks!

Michael

Hi mgertz42,

if you want to explore the schema, the places to start (if you haven’t already found them) are:

The track table has a release column. (You might want to order by position.)

Thanks, but the track table doesn’t have a release column, but a medium column (the recording column doesn’t help much either). I was eventually able to query the tracklist for a release using that table. The SQL query below gives an example for all releases by the artist ‘AC/DC’, sorted by release and position of the track on a release.

Michael

====
select r.id, r.name, t.name, t.position, t.length, m.name, m.position
from track t, medium m, release r
where r.artist_credit = 1352 – 1352 corresponds to artist 'AC/DC’
and t.medium = m.id
and m.release = r.id
order by r.id, t.id

1 Like

Right, there are (potentially) multiple mediums per release.