Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nanadjei2's avatar

Do you put multiple users in the `users` table or create separate tables for each of them `customer` and`admin`

I have been contemplating about this issue for a while. Please I want to know if you are asked to create multiple users for the app where customers, admins, and auditors will be using it, will you create separate tables for them or you you will create a single table and assign roles and permissions ?

0 likes
5 replies
Yorki's avatar

Personally I would implement roles and put all users in one place. If I wanted to extend their data I would go for users_customer_data table or so with customer details. You could join by user_id.

3 likes
Cronix's avatar

single table and assign roles and permissions

that

2 likes
Snapey's avatar

if you can login then you are a user of the application. Logging in is an Authentication topic.

It should not be confused with the role you will have on the site. This is the Authorisation topic.

Sometimes you need to collect information about a user that is different according to their role. This I would store in a profile table.

Just my way....

1 like
Yorki's avatar

You could go like this:

class User extends Model
{
    public function customerDetails()
    {
        return $this->hasOne(CustomerDetails::class, 'user_id');
    }
}
class CustomerDetails extends Model
{
    protected $table = 'users_customer';
    protected $fillable = ['user_id', 'address', 'zip_code'];
}
$user = User::find(1);

//Of course you should handle these user types by yourself
if ($user->isCustomer()) {
    echo $customer->customerDetails->address;
}
2 likes
nanadjei2's avatar

Thank you all for your contribution. I think the decision is clear now :)

Please or to participate in this conversation.