简体   繁体   English

用户帐户的数据库设计

[英]Database design for user accounts

I'm designing a database for a part of school management system. 我正在为学校管理系统的一部分设计数据库。 I'm unsure how to approach designing the users/accounts part so that it is safe and smart once I base my application on it. 我不确定如何设计用户/帐户部分,以便一旦我将应用程序基于它就安全又聪明。

The account roles: student, internship supervisor, school administartion, system admin, superuser. 帐户角色:学生,实习主管,学校管理,系统管理员,超级用户。 Students must take an obligatory internship (table "intern"). 学生必须参加强制性实习(表“实习生”)。 An internship supervisor will supervise them and see the statistics. 实习主管将监督他们并查看统计信息。 School administration is going to see statistics, too. 学校行政部门也将看到统计数据。

The data I want to keep for students is: their student number, first and last name. 我要为学生保留的数据是:他们的学生编号,名字和姓氏。

As for the other roles, they obviously don't have a student number, and having their names is also not a must, but perhaps it would be a good idea - I'm not sure. 至于其他角色,他们显然没有学生编号,也不必一定要有名字,但这也许是个好主意-我不确定。 What do you think? 你怎么看?

And here comes my dilemma: how to design the account / membership /users part of a database so that it's useful, smart and safe for my application? 这是我的两难选择:如何设计数据库的帐户/成员资格/用户部分,以使其对我的应用程序有用,智能且安全? Should I get rid of the "student" table and keep all users in "account" table? 我应该摆脱“学生”表并将所有用户保留在“帐户”表中吗? Or is it better to keep that "student" table and join them with "account" table? 还是保留该“学生”表并将其与“帐户”表结合起来更好? Or perhaps there are some standards and good practices that suggest other approaches? 也许有一些标准和良好做法建议了其他方法? I'm adding umls below: 我在下面添加了umls:

Design 1: 设计1:

设计1

Design 2: 设计2:

设计2

Well, you need to design 6 tables 好吧,你需要设计6张桌子

Users (id, name, email, phone etc)
Userroles (id, title)
users_to_Userroles (many to many) (contains userId and userRoleId)
packages (id, title)
package_rules (id, packageId, discount, free, etc)
packages_to_users (contains userId, packageId)

In this way, you can handle packages and user roles and users data 这样,您可以处理程序包,用户角色和用户数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM