4 ms·
I agree. It also makes queries simpler. It's easier to handle WHERE id = 123 compared to WHERE site = 'HN' and username = 'hot_grill' The last query
by throwaway296273 2y ago
I agree. It also makes queries simpler. It's easier to handle
WHERE id = 123
compared to
WHERE site = 'HN' and username = 'hot_grill'
The last query is easier to write when you are querying the database manually, but I find the first more easy to handle programatically. It's easier to pass an argument from an URL or a message queue in this case.
As systems evolve, you may find that you need a third component to the natural key. If you don't use a simple id, you need to update every query that references the natural key
- hot_gril 2y agoIf you're querying manually, you can still do it the second way even if your pkey is the bigserial.