I think my question is best explained via an example: Suppose I want to write a webserver for streaming music. I have the following columns in the songs
table:
|song_id|song_name|song_genre|song_length|artist
I would like to enable my users to save playlists, but I don't want my playlists to be defined by explicitly specifying the songs that are in the playlist, rather by something like "all songs by ringo starr", which would mean that when new songs by ringo starr are added to the table, the playlist will automatically have them. Actually what I want is a table called playlists
that contains a list of mysql views.
The most naive approach would be to simply have a table called playlists
, and one of it's columns would be called playlist_query
which would store for the above example something like the string "select song_id from songs where artist='ringo starr'
.
This is of course incredibly insecure, but it would suffice in case there is no better solution, since this application is used only internaly inside our company by just a few employees who are all good programmers that know their way around mysql.
So what do you suggest? go with this ugly solution, or is there some easier way to do this?