Creating Charts/Ranking Things Based on User Votes

I’m getting close to finishing my website but there’s still one of the most central concepts of my website that I’m struggling with: Once users give something a rating out of 5 stars, how do I display things in order based on the ratings they get from users?

My website has a database of music info:

A data type called Song (which has fields: Title, Year, Artist, genres, Instruments, etc)

  • Most of those fields are their own data type:
    Instrument (fields: name)
    Artist (fields: name, members)
    Genre (fields: name)

So basically users go to a song page which displays the name of the song etc and they can click on the star rating input but it is not the song as a whole they are rating it is the instruments in the song. For example if the song was ‘We will rock you’ by Queen when the user clicks the ‘Rate’ button it shows an element that has a repeating group of the instruments in that song (vocals, drums, guitar, etc) and next to each instrument is an input to give it a rating.

So I want users to then be able to go to an instrument page for Guitar and see a repeating group of the highest rated songs with guitar in them or to go to a genre page for Jazz and see a repeating group of the highest rated songs whose genres contains 'Jazz".

What’s the best way to setup my database for this? I have been toying with another Data type called:

Song Rating (fields: song, instrument, rating)

Is that a smart way to go about it or is it simpler than that (storing ratings on the user or the song data type instead?)

I thought I had the database setup well but what I’m really struggling with is how to display the songs in the right order (when i “do a search for” i run into problems)

Hope that is clear enough for a general idea of what I’m trying to do.

Any help or advice would be much appreciated.