我目前正在为包含用户的系统创建数据库模型,这些用户可以对某些类别具有权限。简化后,它看起来像这样:
User
- username
- password
Category
- name
我现在想授予用户某些类别的权限,但不授予其他类别的权限。所以我想这样做:
User
- username
- password
Category
- name
Permission
- ForeignKeyField(username)
- ForeignKeyField(Category)
我的问题:这是合乎逻辑的方式还是有更好或更常用的方式?
最佳答案
我唯一看到缺少的是 ID。我会这样设置我的架构:
User
- ID
- Username
- Password
Category
- ID
- Name
Permission
- ID
- UserID
- CategoryID
关于mysql - 如何处理数据库模式中的用户权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19982023/