2008-07-15

On Surrogate keys

I am against the usage of surrogate keys when you have a natural key even being it of type VARCHAR.

There should not be a problem using a VARCHAR as a primary key since if the database is correctly architected it may use internally an integer index to join to other tables. And anyway you always have to lookup the surrogate key from the natural key as the surrogate key should never be exposed outside of the application. You still have to declare UNIQUE the natural key and that will hurt the same (or even more), as having it as PRIMARY KEY, on INSERT.

Is there a REAL performance difference between INT and VARCHAR primary keys?

No comments: