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

ahmedsobhy's avatar

Best approach for different user roles

So I'm creating an LMS where there are admins and students. Students are only registered through admin and they can't register themselves. I was wondering if creating users table for the admins and creating another table for the students and then creating a multi-auth login system OR using users table for both admins and students and have a column with the name of 'student_profile_id' which links to the 'student_profile' table which will have the student info and then by that I can get all admin users by checking if 'student_profile_id' is null. Also, admins will have different permissions. Let me also know if there is a better structure.

0 likes
8 replies
furqanDev's avatar

I'd suggest you to stick with single user table.

You can create status of user and set it whether user is admin or not. You can handle this with middlewares. Using Policies and Gates is a bit difficult with having a different guard in your case you want admin as a second guard. You can create queryScopes for your assistance.

1 like
ahmedsobhy's avatar

Thank you for your reply. I was also wondering if I should have the 'users' table have the 'student_profile_id' column or the 'student_profiles' table have a column of 'user_id'? Is there any difference anyways?

Sinnbeck's avatar

@ahmedsobhy I would assume that a profile belongs to a user. That means that the profile table gets a user_id column

ahmedsobhy's avatar

@Sinnbeck But wouldn't it be a slower query when getting all student users i.e? As you would have to check if each user has a relationship or not instead of just checking if the column is null or not

Sinnbeck's avatar

@ahmedsobhy You can still have a is_student column on the users table. That way it is also possible to create a new student, and have them fill in their profile after.

1 like
Tray2's avatar

@Sinnbeck I agree. Leave the users table as is and add the foreign key to the student_profiles.

Please or to participate in this conversation.