【发布时间】:2011-10-11 06:04:23
【问题描述】:
我刚刚阅读了关于同一主题的以下帖子:
Facebook like notifications tracking (DB Design) 和 Database design to store notifications to users
提供了一些解决方案,但不完全是我所需要的,以及它应该如何用于类似 Facebook 的通知系统。
在通知中,我们经常有一些链接指向执行某些操作的用户、指向他评论过的帖子或视频的链接、指向任何内容的链接,并且通常我们在单个通知中包含多个链接。
notification
-----------------
id (pk)
userid
notification_type
notification_text
timestamp
last_read
通过这种表格结构,我们可以显示单个用户的所有通知,这是一个非常可靠的解决方案。但在这种情况下,我们只能显示纯文本通知。我们不能简单地链接到用户或墙帖。
我正在尝试解决这个问题。一种是将 BB 代码存储在 notification_text 属性中,但随后您需要为 Web 和移动应用程序编写 BB 代码解析器。另一个将创建另一个表,该表派生自该通知表,其中包含我们需要的实体的 ID。一个例子:
PostCommentNotification : Notification
----------------------------------------
id
userId (user who commented on a wall post)
postId (post where comment was made)
现在我们可以编写一个用于显示通知的模板(我们现在不再需要通知表中的 text 属性)然后处理显示它。我对这个解决方案也不满意,因为从通知表派生的表数量可能很大(对于每种通知类型)。
我正在寻找想法! :)
【问题讨论】:
标签: database facebook database-design notifications storage