Admin ,Users ---> separate table VS single table

Published 2 months ago by mac03733

hi guys. i am new to laravel and i know this is probably a matter of preference.

but i am curious which approach is the best

2 months ago (690,170 XP)

Single table for me unless there is a compelling reason not to.

2 months ago (785,240 XP)

users, roles. Or users, with is_admin flag. A user is a user.


Also users, roles. Even if there's a single role, it's easier to extend in the future with separate tables, I find.


are there any major drawback i should worry bout with any of them .. and which questions or likely situations would require one or the other approach


If you decide to build an extra table for the admins you then have to extend the default auth system which is a lot of extra work considering you could simply have a role and do $user->hasRole('admin') when needed.

Another option if you do not want to use roles nor a flag and need extra columns for your admins is to use a one to one relationship. Your admins table can have the user_id as well as the columns you need without messing with Laravel's auth system.

Please sign in or create an account to participate in this conversation.