• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
User Roles & Database

#1
[eluser]malzahar[/eluser]
I'm building an application which will have three different roles and was wondering what would make the most sense in database design and then logic when creating authentication.

If all three groups (admin, editors, users) need the following:
fname, lname, email, password, etc.

but the users group also needs:
field1, field2, field3, field4, etc.

Would it make sense to have a single table containing all three groups and a roles field leaving the user fields empty for admin and editors or three separate tables where I'm repeating the same fields in each table?

Once this is done and I write the authentication part does it make sense to do something like

Code:
$role = $this->session->data('role');
   if ($role == 'user') {
      $this->load->view("admin_area");
   }
   else if ($role == 'admin') {
      $this->load->view("user_area");
   }
}

or to have completely different log in areas.

What are the best practices for handling different user groups?

#2
[eluser]ojcarga[/eluser]
For my side, what i would do is to hold all user in the same db table and has just 1 log in area, that would be more compact and organized.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.