I am designing a database that has multiple types of users, i.e. Administrators, Editors, Teachers and Students. Now all these users have some common fields (CF) and some unique fields (UF) associated to them. I was wondering if this is a good design?
Table Users: [user_id (PK), CF1, CF2,..., CFN, user_type (enum)]
Table Admin: [id (PK), UF_A1, UF_A2, ... , U_AN, user_id(FK)]
Table Editors: [id (PK), UF_E1, UF_E2, ... , U_EN, user_id(FK)]
Table Teachers: [id (PK), UF_T1, UF_T2, ... , U_TN, user_id(FK)]
Table Students: [id (PK), UF_S1, UF_S2, ... , U_SN, user_id(FK)]
where UF_A, UF_E, UF_T and UF_S are unique fields for each of the respective tables.
Now my questions are:
- Is this a good design? If not, how will you design it?
- How do I ensure that a user of user_type teacher is not stores in students table for example?
PS: Some more points if they might help in getting a better insight:
- The database will be used with codeigniter.
- Examples of CF are: username, password, email, profile picture
- Examples of unique fields are: Students(age, enrollment number), Teacher (univ. name, univ. logo, academic degree)