Discussion on:

Message 10 of 76
0 Votes
+ -
Where Natural keys are better than Surrogate keys.
Selecting Surrogate keys is the simpleset decision, no need to think just add a column and set it identity or add a sequence may think a bit more and add rowid or Guid.

But there are cases, that Natural keys are better than Surrogate keys.It is where a good Natural key exists, like when a good code is introduced by the business logic or by a standard like ISO standard. I don't think a surrogate key can be better than ISO country code when you have a Country table, same Currency codes like IRR,SEK and USD are much better than 0,1 and 2. They are better for maintenance, exporting and importing. to be used as foreign key.

I saw many errors, when a programmer joined to tables by wrong pk/fk s and as both keys where numbers, for long time no one could find the problem, but what about this join

.
.
.
Currencies
inner join CurrencyRates on Currencies.Code = CurrencyRates.CurrencyRateID

the error shows up immediately.

I realy have found, many problems in such a n implementation that could be solved using its natural key.
Posted by ebondi
30th Sep 2009