I've got 3 different types of users (entities) that will log into a website in developing for a client.
"FITTER", "CLIENT", "ADMIN"
the first method I came up with was this.
CLIENT TABLE | FITTER TABLE | ADMIN TABLE id | id | id client | title | firstname office | firstname | surname address_ordinal | surname | username postcode | username | password username | password | password | |
a separate table for each user with the usernames and password inside.
This would require the user to select the type of user they want to log in as via a drop down box.
I thought that was rubbish, I just want a form with a username and password box and the application will do all the logic.
so i came up with this:
AUTHENTICATE | CLIENT TABLE | FITTER TABLE | ADMIN TABLE id | id | id | id username | client | title | firstname password | office | firstname | surname type | address_ordinal | surname | type_link | postcode | |
Now there is one table with ALL the usernames and passwords.
The Authenticate.type record would either be a string of "FITTER", "ADMIN" or "CLIENT"
the Authenticate.type_link would be the ID of the table that is in authenticate.type!
So this record...
AUTHENTICATE id | username | password | type | type_link ------------------------------------------------- 3 | john | BF45DE4192DF | FITTER | 4 will authorize whoever's ID is 4 in the FITTER TABLE.
My question is...
Is there a better way to do this?
There must be right?
because this method essentially uses authenticate.type and authenticate.type_link as a composite key.