I have these models(tables): USER
, PHOTO
, BOOK
, QUESTION
etc.
And now I wanna add the favorite
or like
feature to the site, that is user can 'like' some photos or books or questions, and of course a photo can be liked by many users.
So I wanna ask you how to implement this kind of thing.
a page to show the books, photos, quesitons etc which are liked by the current login user; how many people like the book.
Here is my thoughts, give it simple.
A
table: books_users
book_id user_id
table: photos_users
photo_id user_id
table: questions_users
question_id user_id
B
table: users_likes
object_id user_id type
column 'type ' is set to hold the 'book', 'photo' infos.
A or B?
What really bothers me is in OOP we're trying to create a inheritence relationship between the objects that hold the same. But in relational databse, is that good to keep the things in one table(plan B), or keep them seperate(plan A).I don't have too much experiences in DB design so would you please tell the me pros and cons?