栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Facebook之类的通知跟踪(数据库设计)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Facebook之类的通知跟踪(数据库设计)

我不知道这是否是执行此操作的最佳方法,但是由于我没有别人的想法,所以我会这样做。我希望这个答案也能对其他人有所帮助。

我们有2张桌子

notification-----------------id (pk)useridnotification_type (for complexity like notifications for pictures, videos, apps etc.)notificationtimenotificationsRead--------------------id (pk) (i dont think this field is required, anyways)lasttime_readuserid

这个想法是从通知表中选择通知,并加入notificationsRead表,并检查最后读取的通知和ID>
Notificationid的行。并且每次打开通知页面时,都会更新notificationsRead表中的行。

我想查询未读通知的查询将是这样。

SELECt `userid`, `notification`, `time` from `notifications` `notificationsRead`WHERe `notifications`.`userid` IN ( ... query to get a list of friends ...) AND (`notifications`.`time` > (    SELECt `notificationsRead`.`lasttime_read` FROM `notificationsRead`     WHERe `notificationsRead`.`userid` = ...$userid...))

上面的查询未选中。感谢@espais的db design的想法



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/405184.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号