Hacker News new | past | comments | ask | show | jobs | submit login

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




If you're querying manually, you can still do it the second way even if your pkey is the bigserial.




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

Search: