If the user can only have 1 role I don't think you need the user_roles table.
You can simply add a role_id column in your users table.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Trying hard to figure this out.
I have 3 tables.
1.Users (id,name) 2.Roles (id,role_id,role) 3.User_roles (id,user_id,role_id)
User may or may not have more than one role.
Which all relations should I be using?
What I want as a result is this
id,Name,role_id,role (+ other fields) These 4 are the required ones.
I have gone through the docs, but it seems too confusing. Please point me in the right direction. I would really appreciate few lines of how to do instead of direct linking. Thanks a ton. Any help is highly appreciated
Please or to participate in this conversation.