数据库架构:用户团队管理

发布于 2025-01-01 05:39:30 字数 220 浏览 1 评论 0原文

我有用户,他们通过成员资格表成为许多团队的成员。每个团队有一名管理员。

我的问题是:

admin 列 应该是 membership 表中的布尔值,还是 team 表中的整数(用户 ID)?

I have users, who are members of many teams through a membership table. Each team has one administrator.

My question is:

Should the admin column be a boolean in the membership table, or an integer (id of user) in the team table?

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

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

发布评论

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

评论(1

岁月蹉跎了容颜 2025-01-08 05:39:30

最简单的是,是的:在成员资格表中,因为这是用户和团队之间的链接。在这种情况下,您可以更灵活地添加例如 2 个管理员。考虑到明确拥有 1 个管理员是安全的,另一种方法也是有效的。

缺点是,例如,您应该强制执行一种关系,因此 admin_id 始终链接到实际上是团队成员的用户。因此,在删除时,您应该检查该管理员是否确实仍然可用。

进一步思考:考虑一下您是否有多个角色,如果是这种情况,您可能会使用更复杂但更灵活的解决方案,例如 ACL 等。

Most simple is, yes: in membership table as that is the link between a User and a Team. In that case you would be more flexible to add for example 2 administrators. The other way around is also a valid one, considering it secures to have explicitly 1 administrator.

The disadvantage is for example that there is a relation which you should enforce so admin_id always links to a User which is really a member of the Team. So on delete you should check whether this admin is really still available.

A bit further thinking: Consider whether you have multiple roles, if that's the case you might use a more complex but flexible solution like ACL's and things.

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