Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
BarryKeithNoble
Starting Member
9 Posts |
Posted - 2007-08-10 : 04:03:01
|
| HelloI've taken over a database where for many tables the postcode field (equivilent to the US Zip Code) is the obvious primary key. [Mapping postcodes to distict or various types of area for statistical analysis]. However the people who set up the database have continually used an auto generated number for the primary key. There are never any duplicate postcodes in the various tables, so my question is what is the advantage of either using or not using the postcodes as primary keys. |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2007-08-10 : 05:29:16
|
| 'That would be an ecumenical matter!'. (Fr Jack)I do not know your data, but I think it would be brave to assume that the postal code is always going to be unique. Also, UK postcodes can change and while relational theory allows mutable primary keys they can be a pain to handle. (eg Restoring data from long term archive etc.)If you think the postal code is always going to be unique, then you should put an unique constraint on it. I would be inclined to continue using the surrogate as the primary key. |
 |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2007-08-10 : 05:45:37
|
Another thing to bear in mind is that someday some bright spark at the postoffice in one of the countries that your now global company deals with will decide to include alphanumerics in their postcodes - then you'll really be screwed.Duane. |
 |
|
|
|
|
|