I have a website like ebay. people can sell and buy things... I have about 4 tables that I want to get things to show my friends last activities (sell, favorites, likes, comments):
Your friend Joe buy a product from Maria
Your friend Ch follow Bob
Your friend Joe Likes one product
...
1 - So I can create a table: LAST_ACTIVITIES and all activities I will store there.
id
subject_id
object_id
type
verb
data
time
2 - Or I can try to do a select to get friends you follow then get from table sell, favorites, comments and likes this users activities.
like this: (I havent try it, just to show my point)
select id from sells
where user_id in (select follow from following where user =?)
union all
select id from likes
where user_id in (select follow from following where user =?)
union all
select id from favorites
where user_id in (select follow from following where user =?)
union all
select id from comments
where user_id in (select follow from following where user =?)
This tables (sells, likes, follow, comments) can get bigger: (one user follow 1000 people, table likes, comments...).
Which one should I use for activity stream? Why?
Aucun commentaire:
Enregistrer un commentaire