简体   繁体   中英

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:

Design 1:

设计1

Design 2:

设计2

Well, you need to design 6 tables

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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