Primary keys don’t always have to be auto generated. Use ISO codes when possible
I spent quite a lot of time writing audits in April and May of 2018 mostly for security, but sometimes for data models, and I saw one behavior repeat over and over again:
Id(PK) | IsoCode | DisplayName
0 | AUD | OZ Dollar
1 | USD | Freedom Dollar
2 | GBP | Simply Pound
The table above has both auto-generated id, and IsoCode field, that references to the ISO code that team of Swiss standard writers already created. In every single case, I advised dumping the Id
column and using IsoCode
as a primary key - nice people in Swiss already work day and night to make sure that all those codes for countries, currencies, screw sizes, connectors, patterns, cup sizes have its unique id.
IsoCode(PK) | DisplayName
AUD | OZ Dollar
USD | Freedom Dollar
GBP | Simply Pound
See, beautiful, and now when you need to link to the currency - you don't need to look up for a meaningless id - instead you use meaningful ISO code. When you need to store entities with ISO code, or similar in concept unique identifiers in your industry (IEC, IEEE) for example types of connectors - please don’t use auto-generated ids, just use the unique code as the primary key.