Wednesday, April 17, 2013

Common DB developer mistake? Using natural instead of surrogate keys

By Vasudev Ram

Just saw this StackOverflow article:

Database development mistakes made by application developers [closed]

via this Twitter conversation between me and @coding_insights.

The article had this as one of the answers:

"3. Using natural rather than surrogate (technical) primary keys"

followed by an explanation of why that person thinks so.

I tend to agree with that comment, based on my own experience working on many database-backed projects.

Though it seems counter-intuitive, using surrogate keys seems to be a better and more robust approach.

The commenter gave many reasons for using surrogate keys instead of natural keys, (and as I said, I've experienced at least some of those reasons), so I won't repeat them here; go take a look at that article.



- Vasudev Ram - Dancing Bison Enterprises


No comments: