Hello all,
I am making a music player for fun, and have run into a issue thinking about how to structure the data. My first thought was a tree structure where Genre was the root and each genre holds a list of artists, each artist holds a list of albums, each album holds a list of song titles. The problem with this is that albums get split up because some songs on an album have a genre of "rock" and another song on the same album might have a genre called "metal".
Any thoughts on a better approach?
1 reply to this topic
#1
Posted 27 June 2011 - 02:38 PM
|
|
|
#2
Posted 29 June 2011 - 06:48 AM
Eliminate the genre from the table structure, and create a search index data structure for the genres. You could make a simple hash table with the hash key being the genre string, and the hash value being a list of songs belonging to that genre. That way if a user wanted to retrieve a list of songs in one genre, they could do so with minimal lookup time. You could repeat the process for any number of other pieces of metadata you would want to search on, such as album year, publishing studio, song temp, song key, etc.
Additionally, you would want those pieces of metadata to be visible for any one song selected from the tree, so you might want to store all metadata in the leaf nodes along with the song. It would be slow to search on these pieces by traversing the tree, but having them there would make them visible to you for each song, regardless if you searched for it or traversed the tree to it.
Additionally, you would want those pieces of metadata to be visible for any one song selected from the tree, so you might want to store all metadata in the leaf nodes along with the song. It would be slow to search on these pieces by traversing the tree, but having them there would make them visible to you for each song, regardless if you searched for it or traversed the tree to it.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









