Answer the question
In order to leave comments, you need to log in
What is the best way to organize a database for playlists with music?
For the sake of practice, I decided to make a simple Django service with which a person can create playlists of their favorite songs.
Approximate work logic:
There is a table containing the names of all songs of all users, a table of users, a table with playlists of all users. There is also an intermediate table for linking songs to playlists.
When a user registers, a hidden playlist is created for him, where all his tracks are added (even if he did not select a single playlist). When a user adds a track that is not yet in the database, it is added to the main track database and linked to the user through a hidden playlist. If the track is in the database, then it is simply attached to the user. At first glance, nothing complicated.
The problems started when it became necessary to sort the tracks by the date they were added for each user separately. It is necessary that when selecting the tracks go in the order of addition by each individual user, both in the general playlist of the user and in the child ones.
I have 2 ideas how to do it:
Answer the question
In order to leave comments, you need to log in
I would build on the simplicity of building select queries with sorting. As for me, here is the easiest option number 1, add a date field to the playlist. Then you can simply ORDER BY on an indexed field without any additional links.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question