Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

External IDs shouldn't contain any metadata, UUIDv4 should be used for those. UUIDv7 is suitable for database primary keys when simple incremental IDs are not sufficient, but primary keys should really never be used externally.


For some things there's no obvious unique identifier other than a something random. Out of curiosity, do you maintain separate IDs, one internal and one external?


Yea, I usually keep a simple incremental ID or whatever is default for internal IDs, and a separate external ID for entities that are presented externally. For security and not unnecessarily leaking info about the number of records, time and rate of record creation etc. UUIDv4 is convenient for uniqueness, but impractical if the ID needs to be conveyed over phone or written down – or used in URLs, so I often use some system for slugs or short codes in addition to the UUID.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: