社交网站的数据库设计

发布于 2024-09-10 03:54:10 字数 187 浏览 6 评论 0原文

社交网站(例如:Twitter)中会出现哪些表格。

到目前为止我有一个用户表。如何跟踪关注者和我关注的人?

  • 我应该为关注者和我关注的人维护一个单独的表吗?
  • 这些表中会有哪些列?

请不要认为这是主观/偏离主题的。由于我是初学者,我想专家可以指导我获得良好的数据库设计吗?

What are the Tables that would be present in a social networking site (ex: Twitter).

I have a users table as of now. How to keep track of followers and people I do follow?

  • Should I maintain a separate table for followers and people I follow?
  • What are the columns which would be there in those tables?

Please don't think this as Subjective/Off topic. As I am a beginner, I thought experts can guide me to get a good DB design?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

偷得浮生 2024-09-17 03:54:11

尝试查看数据库答案,特别是数据模型。他们针对不同的系统有几种不同的设计。此一个适用于社交网站,它可以让您了解需要什么。

您可能想在 SO 上搜索其他社交网络数据库问题。我发现这个有一个链接到flickr 显示的架构似乎来自 Facebook。

您的数据库设计将基于您的系统要求。如果不确切知道您想要实现什么目标,就很难为您提供最好的设计。

Try having a look at Database Answers in particular the data models. They have several different designs for various systems. This one is for a social networking site which may give you an idea of what's required.

You may want to search on SO for other social network database questions. I found this one that had a link to flickr showing a schema which appears to be from Facebook.

Your database design will be based around your system requirements. Without knowing exactly what you are trying to achieve, it is difficult to give you the best design.

丢了幸福的猪 2024-09-17 03:54:11

您可以使用以下 Messenger 数据库设计概念: Messenger DB

Messenger 数据库架构

you can use this Messenger Database Design Concept: Messenger DB

Messenger DB Schema

指尖上得阳光 2024-09-17 03:54:11

您可以为关注者/被关注的关系创建单独的表。因此,当 x 跟随 y 时,使用 follower_id = x.id follow_id = y.id 创建一个条目。

您可以通过 select * from rows where follower_id = x.id 查询关系表来查找与 x 有关系的所有用户,反之亦然。

当/如果 x 取消关注 y,您只需删除您最初创建的条目即可。

You can create a separate table for follower/ followed relationships. So, when x follow y, create an entry with follower_id = x.id followed_id = y.id.

You can query the relationship table to look for all the users x has relations with by select * from relationships where follower_id = x.id or vice versa.

When/if x un-follow y, you just have to delete the entry you originally created.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文