将admin用户与前端用户放在同一表中是否是好的数据库设计? [英] Is it good database design to have admin users in the same table as front-end users?

查看:194
本文介绍了将admin用户与前端用户放在同一表中是否是好的数据库设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有可以在前端页面上登录的用户,也可以在管理页面上登录的管理员。

I have users who can login on a front-end page, and admins who can login on an admin page.

用户和管理员都应为用户

Should both users and admins be "Users" with different roles, or should they be split in different tables?

推荐答案

角色应该与用户帐户分开跟踪,因为有人可以随着时间的流逝而被提升(或降级)。在这种情况下,在两个不同的表中拥有两个不同的用户帐户是否有意义?我认为不是。

Roles should be tracked separately from user accounts, because someone can be promoted (or demoted) over time. Would it make sense in that situation to have two different user accounts, in two different tables? I think not.

这是我要使用的基本结构-

Here's the basic structure I'd use -


  • user_id(主键)

  • user_name


  • role_id(主键)

  • role_name


  • user_id(主键,外键为USERS.user_id)

  • role_id(主键,ROLES.role_id的外键)

这篇关于将admin用户与前端用户放在同一表中是否是好的数据库设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆