by brettgriffin · 11mo ago · 0 comments
The surrogate key's purpose isn't to directly store the natural key's information, rather, it's to provide an index to it.
> The solution is not to come up with yet another artificial identifier but to come up with better means of identification taking into account the fact that things change.
There isn't 'another' - there's just one. The surrogate key. The other pieces of information you're describing are not the means of indexing the data. They are the pieces of data you wish to retrieve.
That's my whole point: either X becomes a "real world artifact" or it is useless as identifier.
Rather, users traverse that through that object graph, narrowing a range of keys of interest.
This hacker news article was given a surrogate key, 46272487. From that, you can determine what it links to, the name/date/author of the submission, comments, etc.
46272487 means absolutely nothing to anybody involved. But if you wanted to see submissions from user pil0u, or submissions submissions on 2025-12-15, or submissions pertaining to UUID, 46272487 would in that in that result set. Once 46272487 joins out to all of its other tables, you can populate a list that includes their user name, title, domain, etc.
Do not encode identifying information in unique identifiers! The entire world of software is built on surrogate keys and they work wonderfully.
> Do not encode identifying information in unique identifiers! The entire world of software is built on surrogate keys and they work wonderfully.
The amount of manual work required to manage duplicates is in no small part the result of not thinking enough about the identifiers and simply slapping surrogate keys on the data.