dongzha0149 2014-01-03 21:22
浏览 35
已采纳

登录表结构

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?

  • 写回答

1条回答 默认 最新

  • dongqi7631 2014-01-03 21:32
    关注

    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 */
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址