使用国民身份证作为主键
我正在开发一个系统,该系统使用国民 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 @Oded 所建议的,可能会产生法律和隐私影响(这很大程度上取决于您所在的国家/地区)。
隐私问题的一个例子是,在某些国家/地区,个人的出生日期(以及某些国家/地区的性别)是其国民身份证号码的一部分。将其复制到架构中的每个表中可能不是一个好主意,因为这将使限制对此信息的访问变得困难。
最重要的是,还有几个纯粹的技术问题:
我将使用代理主键,并将国家 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:
I would use a surrogate primary key, and would store the national ID as an attribute.
国民身份证是否会成为一个好的密钥很大程度上取决于您的要求。是否需要将国民身份证记录为业务流程的一部分,并且用户/员工/任何人都以这种方式进行唯一标识?您在法律上有权向人们询问该信息吗?他们有义务向您透露其国民身份证吗?如果所有这些都是肯定的,那么将其作为数据库中的键可能很有意义。
确保您了解需要支持的国家身份证标准。例如,长度、数据类型、任何校验位以及是否存在可能与预期规则不匹配的遗留代码或其他正在使用的特殊用途代码。
如果存在隐私问题并且您不需要从数据库中检索实际 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.