Earlier quoted context omitted.
That’s quite the absolute statement to make without even one example.
Maybe? Their statement was that you should "not always add," as opposed to the much stronger "always not add."
You'll regret using natural keys
61–70 of 568 posts
Re: You'll regret using natural keys
#62You think your surrogate key will save you? It will not. The world has an external reality that needs to be reflected in your database. If the unique identifier for your object — VIN, CUSIP, whatever — if it changes, the world will henceforth refer to it by both. You will need to track both. Adding a synthetic key only means you have to track all three. Plus you have to generate a meaningless number, which is actuall…
In the wise words of Patsy, "it's only a model". The real world is resistent to clean abstractions and abstractions are distressingly subject to change. What made your row unique today is quite likely to become non-unique in the days/months/years to come. Always use surrogate keys. Your future self will thank you.
Re: You'll regret using natural keys
#63Another massive annoyance with natural keys - privacy. If your table's primary key contains personal information, that PII now infects every other table that holds a foreign key to that table.
Re: You'll regret using natural keys
#64Earlier quoted context omitted.
Maybe? Their statement was that you should "not always add," as opposed to the much stronger "always not add."
At least the latter provided some examples.
However it will be way more painless to use a timestamp of the script starting point a natural key.
This way when shit happen you have a relevant and stable way to identify each occurrence. And timestamp is easily indexable and ordered.
Re: You'll regret using natural keys
#65Feels like this could have used a few more solid examples up-front. I think another good example would be PlayStation Network using the natural key of "gamer tags" as the primary key to identify players would be a good example. Since this effectively locks players into having to keep a gamertag in order to uniquely identify them in the service -- instead of having a synthetic key that carries no meaning or data other…
yeah the way he described it it's like... well who would ever do that. but foreign keying to emails or usernames is much easier to "accidentally" do and is a classic source of long-term headaches.
Re: You'll regret using natural keys
#66Feels like this could have used a few more solid examples up-front. I think another good example would be PlayStation Network using the natural key of "gamer tags" as the primary key to identify players would be a good example. Since this effectively locks players into having to keep a gamertag in order to uniquely identify them in the service -- instead of having a synthetic key that carries no meaning or data other…
Last I checked, Steam still has me logging in with my two decade old hotmail address as my account name. At least it's not something that shows publicly, I think.
Re: You'll regret using natural keys
#67Re: You'll regret using natural keys
#68Re: You'll regret using natural keys
#69Earlier quoted context omitted.
At least the latter provided some examples.
Here's a real world example if you run a script once every 5 minutes that launch sub-task you might be tempted to add a non natural auto-increment number that identify each occurence to create a link between the script and the subtasks. However it will be way more painless to use a timestamp of the script starting point a natural key. This way when shit happen you have a relevant and stable way to identify each occur…
Re: You'll regret using natural keys
#70With surrogate keys you end up with duplicate entities whenever a partition heals (supposing the entity appeared to both partitions while they were still separate).