使用国民身份证作为主键

发布于 2024-12-22 08:45:35 字数 108 浏览 3 评论 0原文

我正在开发一个系统,该系统使用国民 ID 作为“识别记录”之一,将 nat_id 嵌入所有表中以使查询更容易是个好主意吗?这样做有什么缺点?我只是想征求这里的人们的意见,因为我可能会错过一些重要的事情。

I'm developing a system that make use of national ID one of "identifying record" is it a good idea to embed nat_id in all the tables to make query easier? What are the downsides of doing so? I just want to get opinions from people here in SO because I might miss something important.

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

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

发布评论

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

评论(2

遥远的绿洲 2024-12-29 08:45:35

正如 @Oded 所建议的,可能会产生法律和隐私影响(这很大程度上取决于您所在的国家/地区)。

隐私问题的一个例子是,在某些国家/地区,个人的出生日期(以及某些国家/地区的性别)是其国民身份证号码的一部分。将其复制到架构中的每个表中可能不是一个好主意,因为这将使限制对此信息的访问变得困难。

最重要的是,还有几个纯粹的技术问题:

  1. 并非每个国家都有国家身份证系统,即使有,也使用不同的格式。当您需要适应新格式时,您真的希望必须更改架构中的每个表吗?
  2. 我可以想象一个人可能没有国民身份证的情况(访客?寻求庇护者?无国籍人?)您将如何将它们输入数据库?
  3. 在某些国家/地区,最接近国民身份证的是身份证上的号码,重新签发身份证时该号码会发生变化。换句话说,同一个人在生命的不同阶段可能有不同的身份证号码。

我将使用代理主键,并将国家 ID 存储为属性。

As suggested by @Oded, there may be legal and privacy implications (that very much depends on your country).

One example of a privacy issue is that in some countries the person's date of birth -- and in some countries their gender -- is part of their national ID number. Replicating that into every table in your schema might not be a great idea, since it will make it hard to restrict access to this information.

On top of that, there are several purely technical concerns:

  1. Not every country has a national ID system, and those that do, use different formats. Do you really want to have to alter every table in your schema when you need to accommodate a new format?
  2. I can imagine situations where a person might not have a national ID (a visitor? an asylum seeker? a stateless person?) How are you going to enter them into the database?
  3. In some countries the closest thing to a national ID is the number on the ID card, and that number changes when the ID card is re-issued. In other words, the same person could have different ID numbers at different points in the their life.

I would use a surrogate primary key, and would store the national ID as an attribute.

酷遇一生 2024-12-29 08:45:35

国民身份证是否会成为一个好的密钥很大程度上取决于您的要求。是否需要将国民身份证记录为业务流程的一部分,并且用户/员工/任何人都以这种方式进行唯一标识?您在法律上有权向人们询问该信息吗?他们有义务向您透露其国民身份证吗?如果所有这些都是肯定的,那么将其作为数据库中的键可能很有意义。

确保您了解需要支持的国家身份证标准。例如,长度、数据类型、任何校验位以及是否存在可能与预期规则不匹配的遗留代码或其他正在使用的特殊用途代码。

如果存在隐私问题并且您不需要从数据库中检索实际 ID,那么您可以存储国民 ID 的安全哈希值。

Whether national ID would make a good key or not depends largely on your requirements. Is it a requirement to record national ID as part of the business process and that users/employees/whoever are uniquely identified in that way? Are you legally entitled to ask people for that information? Are they obliged to disclose their national ID to you? If yes to all these then it probably makes good sense for you to make it a key in the database.

Make sure you understand any standards for the national IDs that you'll need to support. E.g. length, data type, any check digits and whether there are legacy codes or other special purpose codes in use that may not match the expected rules.

If there are privacy concerns and you don't need to retrieve the actual ID from the database then you could store a secure hash of the national ID instead.

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