url/user/unique_username VS /user/id/possible_duplicate,我应该选择什么?

发布于 2024-11-13 22:02:46 字数 190 浏览 1 评论 0原文

每当我考虑建立一个内部注册多个用户的新网站时,我总是问自己使用唯一的用户名或重复的用户名是否更好。后者的一个示例是 StackOverflow 站点(因为它使用唯一的用户 ID 而不是唯一的用户名)。

我总是选择前一个选择,但我讨厌它,因为很多时候你就是不能使用你最喜欢的用户名。

我应该选择什么?是否有一些好的建议可以帮助做出决定?

Every time I think to build a new site with multiple users registered inside I always ask myself if it's better with unique usernames or duplicated usernames. An example of the latter is the Stack Overflow site (because it works with the unique user id instead of a unique username).

I always choose the former choice, but I hate it because many times you just can't use your favourite username.

What should I choose? Does some good advice exist for helping to decide?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦行七里 2024-11-20 22:02:46

我认为使用电子邮件地址作为登录的用户 ID 并拥有允许用户选择非唯一昵称的配置文件是最好的方法。电子邮件地址更难忘记,而且不太可能(实际上不可能 - 除了试图开设多个帐户的用户)使您陷入名称冲突。无论如何,您还希望将真实的电子邮件地址作为您的用户配置文件的一部分,因为您希望能够联系您的会员,并且您最终需要向许多/大多数用户发送密码重置电子邮件。

话虽如此,我会为用户配置文件使用内部唯一 ID,例如 IDENTITY 整数或 GUID。这是因为电子邮件地址不是一成不变的。您希望成员能够在不破坏您的外键的情况下更改他们的电子邮件。尽管如此,电子邮件应该是您的用户/成员表中的候选键。

I think using an e-mail address as the user ID for logging in and having a profile which allows the user to pick a non-unique nickname is the best approach. The e-mail address is harder to forget and very unlikely (impossible really - except for users trying to open multiple accounts) to get you into name collisions. You also want to have real e-mail addresses as part of your user profiles anyway because you want to be able to reach your members and you'll eventually need to send a password reset e-mail to many/most users anyway.

Having said that, I would use an internal unique ID for the user profile, such as an IDENTITY integer or a GUID. This is because e-mail address is not immutable. You want members to be able to change their e-mails without disrupting your foreign keys. Still, e-mail should be a candidate key in your user/member table.

千秋岁 2024-11-20 22:02:46

堆栈溢出允许重复名称,但不允许重复用户。 (不是您所说的方式。)每个 StackOverflow 用户都有一个唯一的 ID 号,包括您的(185921)。每个 StackOverflow 用户还有一个可能不唯一的“名称”。

StackOverflow 允许每个用户选择自己的“名称”,但 StackOverflow 代码不使用它。堆栈溢出代码使用唯一的 ID 号。

Stack Overflow allows duplicate names, but not duplicate users. (Not the way you seem to be talking about.) Each Stack Overflow user has a unique id number, including yours (it's 185921). Each Stack Overflow user also has a "name" that might not be unique.

Stack Overflow lets each user pick their own "name", but Stack Overflow code doesn't use it. Stack Overflow code uses the unique id number.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文