用户信息的表设计以及登录凭据? [英] Table design for user's information aswell as login credentials?
问题描述
最初,我想要求您忘记密码或与密码相关的w / e,这个问题与保护密码等无关,我知道/理解这应该如何完成。
考虑到读/写性能,建立一个或多个表时,存储问题数据的最佳方法是什么?
单个表,例如:
表用户:id,username,password,hash,email,
group,access,address,phone,
parents,ts_created,ts_update
多个表, / p>
表用户:id,用户名,密码,
哈希,电子邮件,组,访问,
ts_created,ts_update
表用户的信息:id,user_id,
address,phone,parents,ts_created,
ts_update
如果您的用户的信息字段可能会随时间增长,应该如何处理呢?
例如,新字段:
birthday_date,comments,situation
单表?
如果在这种情况下有多个表,只是为了保持一个带有分隔数据的好的设计,这是否意味着它根本没有用于性能原因?
根据您要存储的数据,您可能需要更多的表格:
- 您在
中使用密码策略,以后用户不能重复使用
a以前使用的密码? - 用户可以拥有多个电子邮件?
- 用户可以属于多个组?
- 用户可以拥有多个电话号码吗?
- 只有一个家长?还是两个?是系统中的父吗?
- What if you use a password policy in the future where a user cannot re-use a previously used password?
- Can a user have more than one email?
- Can a user belong to more than one group?
- Can a user have more than one phone number?
- Only one parent? Or two? Is the parent in the system? What information about the parent do you store?
存储这样的想法可能值得存储在自己的单个表中,这意味着在未来它应该是很容易维护。你需要考虑系统将如何改变。至于性能,如已经概述的,只要你创建正确的索引,并且正确使用数据库,它不应该是一个问题。
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.
What is the best approach to store the data in question, considering performance on read/write - to build one or more tables?
Single table, for example:
Table users: id, username, password, hash, email, group, access, address, phone, parents, ts_created, ts_update
Multiple tables, for example:
Table users: id, username, password, hash, email, group, access, ts_created, ts_update
Table user's information: id, user_id, address, phone, parents, ts_created, ts_update
What if your user's information fields may grow along the time - how should you deal with it ?
For example new fields: birthday_date, comments, situation
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 ?
If you want real sql examples let me know and I will scrap something to update this.
You may need even more tables depending on the data your going to 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屋!