我正在开发一个 Web 应用程序,该应用程序将支持每个用户具有相应角色的用户身份验证。此外,我的用户可以是不同的类型,并且具有与之关联的不同字段。每个用户拥有的某些字段是相同的,例如:
email, password, first_name, last_name, etc.
Run Code Online (Sandbox Code Playgroud)
但是不同用户类型的一些字段会有所不同。例如:
User Type: Instructor
Fields unique to this type of user
----------------------------------
hourly_rate, tax_status
==================================
User Type: Student
Fields unique to this type of user
----------------------------------
instrument, monthly_charge, program
==================================
User Type: Employee
Fields unique to this type of user
----------------------------------
hourly_rate, location
Run Code Online (Sandbox Code Playgroud)
这是在这些类型的用户之间可以相似和独特的字段类型的简要示例。
我想到的可能设置是:
Table: `users`; contains all similar fields as well as a `user_type_id` column (a foreign key on `id` in `user_types`
Table: `user_types`; contains an `id` and a `type` …
Run Code Online (Sandbox Code Playgroud)