Multiple Login area
User is assigned to a group ID. There are multiple login area, eg: frontend, backend and the control panel l开发者_StackOverflow中文版ogin.
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:
- Will there be ever a situation where you would have more login areas or there are only 3 login areas?
- Will there be a situation where user belonging to one group needs to have login access to all 3 areas or 2 areas?
If your answers to both question is yes then it would make sense to have first example design.
tbl_user
UserID | firstName | Email | Password | LoginArea | GroupID
1 , Bill , email@email1.com , passwordhash344, Backend | 2
2 , Paul , email@email2.com , passwordhash123, Backend | 3
精彩评论