Question

So I've got this feature I'm building to allow users to save profile's to a list. Kind of along the lines of a playlist with a name of the list, the user's id and the unique profile data as an array with both the profile id and the state's abbreviation that the profile is in.

More specifically I'm wondering whether or not I should have the list be a single row in a table with these columns: list_id, list_name, user_id, serialized_list.

Where the serialized_list column is an array containing the state key and the profile id.

The other alternative I came up with is something like having two tables. One with the columns: list_id, list_name, user_id.

The other with a row for each list item: row_id, list_id, state, profile_id.

I'm kind of a database n00b, so I'm not entirely sure what considerations should even be made, but I guess I'm asking which of these (or another alternative) would be better with respect to speed and maintainability?

Was it helpful?

Solution

I always find it best to do it the second way you mentioned as you directly call the rows rather than have to strip out the serialized list. If you are going to be looking up profile_id and state from the serialized list, you can easily have that within the same query doing it the second way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top