I need to assign 4 roles.
The role has User , Manager , Admin , Super Admin
and some User will have 2 roles
each role There will be different personal information.
and giving a role to User will go through Register
I’m not sure what’s the best way to create a table.
I’m supposed to create 4 tables separated by roles.
Or how should I create the table?
please help me
and if possible I would also like to know how to set roles for page access. or query MySql
2
Answers
Created two tables will be needed. One table for roles with (userid and roles_name), another table for the user table with (roles_id) column, roles_id is foreign key from the roles table.
You can try creating 3 tables Users, Roles and User has Roles as follow
User table
users
Role table
roles
User has Roles table
user_has_roles
To assign role to any users you can assign it by passing
role_id
anduser_id
inuser_has_roles
tableHere is sample SQL schema