using the ISO 3 digit code is a good design call, others may have been tempted to use an autonumber column
Quote:
|
One data-set is about storing country and its neighboring countries. I am thinking of creating a table with 2 columns (country1 code, country2 code along with a auto-incr pkey column) which stores this info: For e.g. US, Mexico; US, Canada etc. But this leads to a large amount of data duplication (e.g. Mexico;US).
|
what you have is an adjacency model.
I don't think you need the auto increment column. storing pairs is good enough in my books
There will be a problem of data duplication if you allow the users to put in information willy nilly. I'd suggest in your front end you control how these adjacency rules are defined by forcing the pairing to be in alphabetic order, and use both columns as the primary key and both columns indexed
fer instance
looking at Central Europe And the Czech republic
Austria - Czech
Czech - Germany
Czech - Poland
Czech - Slovakia
when you search for adjacency your where clause will have to look in both columns
eg
Adjacencies
Country1
Country2
SELECT my, column, list from mytable
JOIN <some join criteria>
WHERE country1 = 'GBR' or country2 = 'GBR'