Inside a Facebook group there is a feature when every time see the group newsfeed it mark all posts as seen by me.
And if I see a specific post inside a group thought a url (facebook.com/groups/123/posts/123), it mark as seen this single post.
My question is about what is the intuitive way and right to model this and performance. I want to know what I am missing or wrong about about to get it right.
What happens on facebook: "When a new member join the group, all the old posts are marked as seen by him". But is it per post or global?
Scenarios:
Mark as seen all individual posts when click group.
Pros:
- Easy development
- Easy and fast queries. Could implement a int counter column on each post and a has_many table users_id x post_id
- Getting and individual post I can tell how many users saw without context
Cons:
- How to deal with a new member join a group with > 100 posts? Batch writes?
2.Mark as seen the group when click group.
Pros:
- One single write when seen a group
Any tips and advices are welcome! Thanks!
INSERT INTO user_posts SELECT post_id, new_user_id FROM posts p WHERE p.group = 'newly joined group'
? wouldn't suffice?