New to database design, and I was wondering how to effectively create something like Facebook, taking into account future scalability.
Let's say you have 3 tables: users, photos and albums. Say a user may like either a photograph or an album.
Should I use 1 table for both types of likes? This would probably mean that the user would have user_id, like_type (0-photo, 1 album, etc.), for example_value (id value of any content, be it photo_id or album_id)?
or do you have 2 different tables for each one you like (e.g. photos_likes and albums_likes)? which will only contain user_id and photo / album_id
I want the database design to be clean and semi-scaled, whether we will add many more objects in the future (videos, comments, notes, etc.) or tons of favorites.
Thanks!
source share