Click to See Complete Forum and Search --> : table organization for multiple user roles?


taz
05-29-2009, 01:12 PM
Hi,

I'm trying to create a database layout for a website with 3 user roles: admins, buyers and sellers

Each type of user has a very distinct profile with only a small number common fields.

I'm wondering how I would organize the authentication process?

Right now I would have to SELECT from the 3 tables every time someone logged in to find out what type of user it is.

On the other hand, I thought about creating a "login" table where I would just store: email, password and role.

So then when someone logs in I just do a SELECT from the login table and then based on the role, load the profile info from the corresponding table (admins, buyers, sellers).

Is there any kind of best-practice for this scenario?

Can someone suggest an ideal setup?

Thanks!

Jeff Mott
05-29-2009, 06:11 PM
Right now I would have to SELECT from the 3 tables every time someone logged in to find out what type of user it is.

Selecting from three tables won't affect the performance. So your best bet is to keep what it sounds like you already have: a table for users, a table for roles, and a table linking users and roles.

taz
05-29-2009, 06:27 PM
thanks!