如果我有一个用户表但想要将电子邮件作为用户名,我应该只将电子邮件/密码作为列吗?

时间:2022-11-15 20:06:15

Or should I have username, email, password and set save username also as email?

或者我应该有用户名,电子邮件,密码和设置保存用户名也作为电子邮件?

edit: I am not using email as the pk but am using a unique index on the email

编辑:我没有使用电子邮件作为PK,但我在电子邮件中使用唯一索引

I feel like if I decided to change to openid/usernames I can still do that in the future by adding another column

我觉得如果我决定更改为openid / usernames,我将来仍然可以通过添加另一列来实现

2 个解决方案

#1


2  

I'd do email/password. And if you ever want to add usernames you can upgrade it then. No need to use extra fields if they're the same and you don't need them.

我会做电子邮件/密码。如果您想要添加用户名,则可以升级它。如果它们是相同的并且您不需要它们,则无需使用额外的字段。

#2


1  

Might as well just have the email column since it functions as both, no point in repeating data in your table. Just remember DO NOT SAVE PASSWORDS AS CLEARTEXT :) Also you should have a Primary Key id column

也可能只有电子邮件列,因为它既作为两者,也没有重复表中的数据。请记住,不要将密码保存为CLEARTEXT :)此外,您应该有一个主键ID列

#1


2  

I'd do email/password. And if you ever want to add usernames you can upgrade it then. No need to use extra fields if they're the same and you don't need them.

我会做电子邮件/密码。如果您想要添加用户名,则可以升级它。如果它们是相同的并且您不需要它们,则无需使用额外的字段。

#2


1  

Might as well just have the email column since it functions as both, no point in repeating data in your table. Just remember DO NOT SAVE PASSWORDS AS CLEARTEXT :) Also you should have a Primary Key id column

也可能只有电子邮件列,因为它既作为两者,也没有重复表中的数据。请记住,不要将密码保存为CLEARTEXT :)此外,您应该有一个主键ID列