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

cristian9509's avatar

Storing default user type roles

I have multiple user types and each user type would need to be assigned different roles. However, I also build the application with Modules that can be selected by users when they subscribe. Each of the Modules comes with their own set of roles.

What I have so far is to place all the roles into a Roles table and have two many-to-many tables linking the user_types and models.

user_types -> user_type_role <- roles models -> model_role <- roles

Then my user can have assigned only one user_types and can have multiple roles. user -> user_role <- roles user -> user_models <- models

When a user subscribes, chooses a user_type and then the modules, I retrieve all the roles from both user_type_role and module_role and I sync then to user_role table. DO I need to do this sync?

Or, better said do I put everything in my user_role and go from there when I check for roles and permissions or should I retrieve them directly from user_type_role and module_role so I avoid redundant data?

Imgur

0 likes
0 replies

Please or to participate in this conversation.