PHP/MySQL 带组的用户系统

发布于 2024-08-28 10:11:50 字数 178 浏览 1 评论 0原文

我在“用户”表中设置了用户系统,在“组”表中设置了组。本质上,我希望用户能够加入他们想要的任何和所有群组,就像在 Facebook 上一样。

如何在 mysql/php 数据库系统中构建这一结构?只要快速总结一下就会很有帮助!

我环顾四周,但只能找到有关创建“组”的信息,其中用户只有 1、2 或 3 级权限。

I have a user system set up in a 'users' table, and I have groups set up in a 'groups' table. Essentially, I want users to be able to join any and all the groups that they want, in the same was as one would on facebook.

How would one go about structuring this in a mysql/php database system? Just a quick summary would be helpful!

I've looked around, but I can only find info on creating 'groups' where the users just have a sort of 1, 2 or 3 permission rank.

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

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

发布评论

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

评论(1

初吻给了烟 2024-09-04 10:11:50

我会有一个类似的数据库:

|--------|             |-------------|            |------|
| Group  | ------- 1.* | JoinedGroup | *.1------- | User |
|--------|             |-------------|            |------|

所以 JoinedGroup 拥有一个 UserId 和一个 GroupId。当用户想要加入组时,只需向 JoinedGroup 表添加一行即可。

从某个组中选择用户只需要一个简单的内部联接。

I would have a databse something like:

|--------|             |-------------|            |------|
| Group  | ------- 1.* | JoinedGroup | *.1------- | User |
|--------|             |-------------|            |------|

So the JoinedGroup holds a UserId and a GroupId. When a user wants to join a group just add a row to the JoinedGroup table.

Selecting users from a certain group would just require a simple inner join.

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