I am curious to know what would be the preferred method for a table which would store a list of IDs associated with a UserID.
Should I have one field storing a serialized array of all the id’s (one row per UserID)
Or one row for every id for every player? Is the answer clear cut or are there factors to take into account when making such a decision?
Hope you can help explain the best choice.
if you’re going to get the whole list of IDs everytime or most of the time, or if the lists of IDs are short, then serializing them is fine (though I wouldn’t recommend it anyway)
However you’ll be missing out on indexing if you ever need to search for a user using an ID in the list of IDs as a constraint.
Best way is to have a separate table storing the many-to-many relations (which is what I’m assuming you want). If you have a one-to-many relationship, then you should reverse the way that you are referencing the relation and add a user_id column to the table containing the IDs .