User is assigned to a group ID. There are multiple login area, eg: frontend, backend and the control panel login.
I am wondering should I keep LoginArea in seperate table or what is alternative way?
Example:
tbl_user
UserID | firstName | Email | Password | LoginArea | GroupID
1 , Bill , email@email1.com , passwordhash344, Backend | 2
2 , Paul , email@email2.com , passwordhash123, Backend | 3
or
tbl_user
UserID | firstName | Email | Password | GroupID
tbl_group
GroupID | LoginArea | Group_Name
0 , Frontend , Customer
1 , Backend , Admin
2 , Backend , Staff
3 , Backend , Sales
20 , ControlPanel , Shop
//Note GroupID is not PK
So if I want to login to backend, I need to make sure I am on the backend login first. Use SQL something like this?
SELECT count(*) FROM members
WHERE email = 'emailhere' AND
password = 'password' AND
LoginArea = 'Backend'
That just to make sure customer login detail wont work on the backend login area.
There are certain things to consider here:
If your answers to both question is yes then it would make sense to have first example design.