用户信息和登录凭据的表格设计? [英] Table design for user's information as well as login credentials?

查看:162
本文介绍了用户信息和登录凭据的表格设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最初,我想让您忘记哈希密码或与密码有关的哈希,这个问题与保护密码无关,等等,我确实知道/理解该怎么做。

Initially I would like to ask you to forget about hashing passwords or w/e related to passwords, this question is not related to securing passwords, etc and I do know/understand how this should be done.

考虑到读/写性能-构造一个或多个表,存储有问题数据的最佳方法是什么?

单个表,例如:


表用户:ID,用户名,密码,哈希,电子邮件,
组,访问权,地址,电话,
个父母,ts_created,ts_update

Table users: id, username, password, hash, email, group, access, address, phone, parents, ts_created, ts_update

多个表,例如:


表用户:ID,用户名,密码,
哈希,电子邮件,组,访问权限,
ts_created,ts_update

Table users: id, username, password, hash, email, group, access, ts_created, ts_update

表用户信息:id,user_id,
地址,电话,父母,ts_created,
ts_update

Table user's information: id, user_id, address, phone, parents, ts_created, ts_update

如果您的用户的信息字段可能沿着t增长,该怎么办ime-您应该如何处理?

What if your user's information fields may grow along the time - how should you deal with it ?


例如新字段:
Birthday_date,评论,情况

For example new fields: birthday_date, comments, situation

在查询中有2个表会比有一个表慢吗?

Will having 2 tables be slower on queries than having a single table ?

如果在这种情况下拥有多个表仅是为了维护一个具有分离数据的良好设计,这是否意味着出于性能原因它根本没有用?

If having multiple tables in this case is only for maintaining a good design with separated data, does that mean it is not useful at all for performance reasons ?

如果您想要真正的sql示例,请告诉我,我将抓取一些内容进行更新。

推荐答案

您可能需要更多表,具体取决于要存储的数据:

You may need even more tables depending on the data your going to store:


  1. 如果您将来在
    中使用密码策略,导致用户无法重复使用
    a先前使用的密码?

  2. 用户可以有多个电子邮件吗?

  3. 用户可以属于多个组吗?

  4. 用户可以拥有多个电话号码吗?

  5. 只有一个父母吗?还是两个?父母在系统中吗?您存储有关父母的哪些信息?

  1. What if you use a password policy in the future where a user cannot re-use a previously used password?
  2. Can a user have more than one email?
  3. Can a user belong to more than one group?
  4. Can a user have more than one phone number?
  5. Only one parent? Or two? Is the parent in the system? What information about the parent do you store?

存储认为这样可能值得存储在其自己的单独表中,这意味着将来应该更容易维护。您需要考虑系统将如何变化。至于性能,正如已经概述的那样,只要您创建正确的索引并正确使用数据库就不成问题。

Storing thinks like this may be worth to store in its own individual table, which means that in the future it should be a lot easier to maintain. You need to think of how the system will change. As for performance, as already outlined it shouldn't be a problem as long as you create the correct indexes, and use the database correctly.

这篇关于用户信息和登录凭据的表格设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆