Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My main concern is, will one country ever adopt a numeric code that has been used for another in the past, such as can happen with alphanumeric 3166-1 codes? If not, then it seems like a perfect identifier for a primary key in a database...

share|improve this question
add comment

1 Answer 1

Coming from a pure database perspective. No you should not. For the following reasons:

  1. According to this: http://en.wikipedia.org/wiki/ISO_3166-1_numeric#Deleted_codes some codes have been changed. While this will create a mess in all systems this mess will be compounded by the fact that primary keys tend to be harder to change than normal columns.
  2. Security reasons: see this: http://stackoverflow.com/questions/7451348/should-primary-keys-of-mysql-tables-be-exposed
  3. Have something such as a primary key under the control of any other organization can lead to trouble.
  4. Strings as primary keys are less "efficient" than numeric keys. I am basing that solely on the fact that a string or character representation needs to be unboxed when used in code and am not talking database implementation. It is also a string since some country codes are prefixed with a zero
share|improve this answer
1  
I think you misread the question a little. I wish to use ISO 3166-1 numeric codes for the primary key, not the 3-character-long codes which can change. Having said that, point 3 is valid for me. –  CrazyTim Dec 20 '12 at 3:51
    
Regarding point 3, I guess it is inherently insecure, and wouldn't be good to do in practice. But on the other hand it is convenient, and a good reference system to use, to sync the table should the codes change, which is why I thought to do it. –  CrazyTim Dec 20 '12 at 3:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.