Facebook如何将粉丝动态通知墙更新? [英] How facebook notify wall updates to fans?

查看:54
本文介绍了Facebook如何将粉丝动态通知墙更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发社交媒体应用,我希望用户可以选择在页面创建新帖子时(例如在Facebook中)收到通知.首先,我创建一个包含以下内容的 Notification 表:

I working on social media app and I want users to have option to be notified when page create new post (as in facebook). First, I create a Notification table that contain :

Id(PK)
UserId
PageId
PostId
ReadBit
Date

但这没有意义.如果页面上有1000个甚至500个感兴趣的粉丝,那么逻辑上就不会为每个感兴趣的粉丝创建1000或500条记录.还有另一种方法吗?

But this doesn't make sense. If page have 1000 or even 500 interested fans, it doesn't not logically to create 1000 or 500 record for every interested fan. Is there another method to do that ?

推荐答案

您正在谈论两种类型的信息:页面和帖子.

There are two types of information you are talking about: Pages and posts.

当用户选择进入页面时,该页面应该是持久的,因此您需要一个代表该页面的数据库条目.标准的处理方式是每个用户和她订阅的每个页面都有一条记录:

When a user opts in for a page, this should be persistent, so you'll need a database entry representing this. The standard way to go is to have one record per user and per page she subscribed to:

Subscription(id, user_id, page_id)

根据确切的要求,可能存在更简单的解决方案.例如,如果页面是关于主题的,而用户不是订阅页面而是主题(例如,有50个关于汽车的页面,有70个关于计算机的页面),则按用户和主题存储订阅就足够了.但是您的文字并未表明这一点.

Depending on the exact requirements, there might exist simpler solutions. E.g., if the pages are about topics, and the user doesn't subscribe a page but a topic (like there are 50 pages about cars, and 70 about computers), it would be sufficient to store a subscription per user and topic. But your text doesn't indicate this.

第二个问题是在页面上发布帖子后如何跟踪通知过程.严格来说,每个此类通知都不需要数据库记录.页面更改后,使用订阅"表查找所有订户,并在其上循环生成通知.

The second question is how to track the notification process when a post has been made to a page. Strictly speaking, you don't need a database record for each such notification. When a page has changed, look up all subscribers using the Subscription table, and in a loop on them generate the notifications.

仅当您需要有关每个此类通知的一些其他持久性信息时,每个通知才需要一条记录,即

Only in case that you need some additional persistent information about each such notification you will need a record per notification, i.e.

Notification(id, subscription_id, ...)

如果您需要在发送通知时存储时间戳,或者对于通知过程有一些状态信息,例如:用户是否对通知做出了反应.

This might be the case if you need to store the timestamp when the notification was sent, or if you have some status information for a notification process, e.g. whether the user has reacted on the notification.

这篇关于Facebook如何将粉丝动态通知墙更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆