对于用户“关注”/“朋友”的网站来说,什么是好的数据库结构?其他用户?

发布于 2024-10-20 05:17:12 字数 249 浏览 1 评论 0原文

我正在为一个 Web 应用程序构建一个数据库,其中包含相互关注的用户。什么才是好的设计?我当时在想:

TABLE: users ROWS: user_id, name, pass, email, activated, user_level, registration_date
TABLE: relationships ROWS: relation_id, user_id, followed_id

你对此有何看法?

I am building a database for a web application that includes users following each other. What would be a good design? I was thinking this:

TABLE: users ROWS: user_id, name, pass, email, activated, user_level, registration_date
TABLE: relationships ROWS: relation_id, user_id, followed_id

What do you think of that?

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

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

发布评论

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

评论(1

梓梦 2024-10-27 05:17:12

对于用户表,我想你所拥有的是正确的。如果您需要添加更多列,您可以简单地更改该表,或者添加具有一对一关系的附加表。

至于关系表,我认为这是正确的。尽管我不会将其称为 followed_id。我建议您可以将该表用于许多不同类型的交互,因此我将其称为 user_idinteracter_id,而 relationship_id 将是许多不同类型的交互(关注、戳等)。

For the user table, I guess what you have is correct. If you need to add more columns, you could simply alter that table, or add an additional table with a one to one relationship.

As for the relationships table, I think that is correct. Although i wouldn't call it followed_id. I would suggest that you could use that table for many different types of interactions, so I would call it user_id and interacter_id and the relationship_id would be a number of different types of interactions (follow, poke, etc).

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