Answer the question
In order to leave comments, you need to log in
How to split the user table correctly?
Good afternoon, tell me
how to make it more correct:
if there are three types of Users and they have completely different functions and, most importantly, a different service interface
(i.e. different registration / profile / main menu / etc.),
but some basic properties are the same, such as,
(settings / roles / invitations /review/comments/etc)
How to properly model the database in this case?
Thanks in advance
s/s
this is not about the admin/user
Answer the question
In order to leave comments, you need to log in
found the right solution to my problem
richardbagshaw.co.uk/laravel-user-types-and-polymo...
this is in particular for laravel but I think that it is possible to apply in raw php
the essence is that there is one table Users and several tables User_Users / User_sellers
in the main table have user_type and user_id as foreign keys to additional tables
If there are minor differences, then one table, column - type - work wonders based on the type, if the changes are significant - then one table with general data + type and auxiliary tables for each type (unless, of course, the number of types is not 100500)
Add boolean fields to the User model: is_admin, is_user, is_chert_lisiy. Normal actions will be common to all users, and for special actions, just control these fields. This, among other things, will allow you to easily change the type of user.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question