该表需要一两个唯一键索引吗?

发布于 2024-07-10 02:24:04 字数 349 浏览 6 评论 0原文

我正在尝试创建一个仅包含 OpenId 注册的 Users 表,就像 StackOverflow 一样。

我在表中存储

  • OpenId 标识符(他们的登录名)
  • 别名(向公众显示的显示名称)
  • 其他一些 openId 内容

所以...我想确保系统中只有一个用户具有 openId 标识符和只有一个别名。

当然,我可以随时更改我的别名。 我还可以随时更改我的 openId 标识符。 我需要确保它们是唯一的/仅存在一次。

那么...我应该为表创建两个唯一键索引,还是创建一个包含两个字段的唯一键索引?

干杯:)

I'm trying to create a Users table that only has OpenId registrations, exactly like StackOverflow.

I'm storing in the table

  • OpenId Identifier (their login name)
  • Alias (which is the display name to show to the public)
  • Some other openId stuff

So... I want to make sure that there is only ONE user in the system that has the openId identifier and only one alias.

Of course, I can change my alias at any time. I could also change my openId identifier at any time. I need to make sure that these are unique / only exist once.

SO... Do I create TWO unique key indexes for the table, or one unique key index with both fields in it?

Cheers :)

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

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

发布评论

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

评论(2

迷迭香的记忆 2024-07-17 02:24:05

他们每人一份。

如果您只创建一个包含两者的用户,例如,两个用户具有相同的别名,只要他们有两个不同的 OpenID。

但是:

  • 我建议您创建一个用户表和另一个 OpenID 表,以允许用户将多个 OpenID 与其帐户链接。 假设他们在 Yahoo 拥有一个 OpenID,在 MyOpenID 拥有另一个。 如果 - 由于某种原因 - 雅虎决定关闭其 OpenID 服务,该人仍然可以使用他的 MyOpenID 登录名进行登录。 好吧,只要他之前用自己的账号注册过这个ID就可以了。

One for each of them.

If you'd create just one that contains both you could have - for examlpe - two users with the same alias, as long as they have two different OpenIDs.

However:

  • I'd suggest, that you create one User Table and another OpenID Table that allows users to link more than one OpenID with their account. Let's say, they have an OpenID at Yahoo and another at MyOpenID. If - due to whatever reason - Yahoo decides to shut down it's OpenID service the person would still be able to log in with his MyOpenID Login. Well, as long as he has registered that ID with his account earlier.
那小子欠揍 2024-07-17 02:24:05

制作两个唯一的密钥。 否则,同一 openid 可以关联多个用户。

Make two unique keys. Otherwise, the same openid can have more than one user associated.

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