douquan2023 2013-08-02 15:35
浏览 49
已采纳

拥有订阅者功能的最佳方式是什么? 我应该在用户或订阅页面下存储订阅/订阅者列表吗?

I have a list of pages and a list of users. A user can subscribe to any number of pages and a page can have any number of subscribers. How should I store the subscriptions? Have each user have a list of their subscriptions or have each page have a list of its subscribers? The tough part that I need to get around is easy searchability. A page must display its list of subscribers and a user must have a list of their subscriptions. But if the data is stored one way, then it is harder to get to the other way. How would you get around this problem?

  • 写回答

1条回答 默认 最新

  • doutao5499 2013-08-02 15:37
    关注

    Many-To-Many relationships are traditionally stored using a Junction Table.

    Have two columns, both foreign keys, one being the primary key of the user table and the other being the primary key of the page table. Then either have a seperate primary key, or make your primary key a composite of the two foreign keys.

    You can then join in either direction across the three tables.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?