I have a database 'practice'.I`m trying to make database that allows users to Login and submit data in forms.
The admin adds the username and the password for few users.The users then login using the password and username.
Now Since the admin adds users his functions must be different from the users and a different page is to be loaded for him so to identify admin.I have added the following admin column in the table.
authenticate table
username | password | admin
----------------------------
admin | 7821y34n | 1
007 | 435432 | 0
admin is of type tinyint if 1 then admin if 0 then user
Is this the way to create an authenticate table?
A good practice is to map a ROLE
table to a USER
table this way a user could have multiple roles.
For your second question as I sayed in the comments I would put all data in the user
table but if you need to separate data in two tables you could do it this way.
Just by mapping user_details
table to the user
table. (user_id
in user_details
)
Table USER
ID | USERNAME | PASSWORD
-------------------------
1 | bill | 09hk4352 /* password should be encoded */
2 | frank | 7dfs3454
Table USER_DETAILS
ID | DOB | USER_ID
------------------------
2 | 1988-05-12 | 1
Table ROLE
ID | ROLE
---------------
1 | ROLE_USER
2 | ROLE_ADMIN
3 | ROLE_GUEST
Table USER_ROLE
ROLE_ID | USER_ID
------------------
1 | 2 /* user "frank" has ROLE_USER */
2 | 2 /* user "frank" has also ROLE_ADMIN */
1 | 1 /* user "bill" has ROLE_USER */