data model for notification in social network?

Viewed 960

I build a social network with Neo4j, it includes:

Node labels: User, Post, Comment, Page, Group

Relationships: LIKE, WRITE, HAS, JOIN, FOLLOW,...

It is like Facebook.

example: A user follow B user: when B have a action such as like post, comment, follow another user, follow page, join group, etc. so that action will be sent to A. Similar, C, D, E users that follow B will receive the same notification.

I don't know how to design the data model for this problem and I have some solutions:

  1. create Notification nodes for every user. If a action is executed, create n notification for n follower. Benefit: we can check that this user have seen notification, right? But, number of nodes quickly increase, power of n.
  2. create a query for every call API notification (for client application), this query only get a action list of users are followed in special time (24 hours or a 2, 3 days). But Followers don't check this notification seen or yet, and this query may make server slowly.
  3. create node with limited quantity such as 20, 30 nodes per user.
  4. Create unlimited nodes (include time of action) on 24 hours and those nodes has time of action property > 24 hours will be deleted (expire time maybe is 2, 3 days). Who can help me solve this problem? I should chose which solution or a new way?
1 Answers
Related