I have a database of “assets” that users can favorite. What’s the best way to create this function? I have thought of 2 ways but both is not perfect:
First way is to create a new column in my “users” table called “favorites” with an array of asset ids that the user have favorited. I guess this could be confusing since everything is squished into an array.
Second way is to create a new database table called “favorites” and we table in any new favorites into this table. But the problem with this is what happens if someone decides to “unfavorite” something?
Ideally, I want to query the “assets” and be able to filter by the user’s “favorites” - “all assets”, “favorited assets”, etc. Which is better? Or is there another way?