开发者

'Follow' or 'Subscribe' method

I want to know how Follow system in Twitter or Subscribe in Youtube method in PHP and MySQL. How it is work in the database?

Do I have to create "subscribes" table which contain information for a user that following a content/other user's publication.

E.g If someone follow/sub someone, my app create a new row in the table e开发者_如何学Pythonxample user:userA action:follow who:userB

So if userA open userB's content, I have to search this table if userA already follow userB or not? Or there are easier method?

Thanks.


For an easy subscription System:

table_user

  • id
  • name

table_subscriber

  • id_user_subscriber -> points to table_user -> id
  • id_user_provider -> points to table_user -> id

if you want to keep track if the subscriber has seen the new post alredy, you have to create another table:

table_post

  • id
  • name

table_subscriber_post

  • id_user_subscriber -> points to table_user -> id
  • id_post -> points to table_post -> id

If the user has seen the post, create an entry in the table above

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜