I currently have the following tables
Nation
----------------
Id (int) primary key autoincrement
Name (char)
City
----------------
Id (int) primary key autoincrement
NationId (int) references Nation(Id)
Name (char)
Nation table data
Id Name
----------
0 England
1 USA
City table data
Id NationId Name
-----------------------
0 0 London
1 0 Manchester
2 1 New York
3 1 Boston
The above is part of a database that I would want to redistribute to users of my application.
The users of my application will be allowed to add their own nations and well as cities. When they add their own city, as per the current database design, it would obviously increment the City.Id primary key value.
However, I would want to at some stage, allow users the ability to 'push' or 'pull' nations/cities from each other's database. For example. User1 has the additional value in his city table:
Id NationId Name
-----------------------
4 1 California
5 1 Chicago
While User2 has the following in his city table:
Id NationId Name
-----------------------
4 1 Houston
5 1 Phoenix
Each wants to have each other's cities in their city table. Once each has pushed their different cities data across, their City.Id, City.Name attributes won't quite correspond.
User1:
Id NationId Name
-----------------------
0 0 London
1 0 Manchester
2 1 New York
3 1 Boston
4 1 California
5 1 Chicago
6 1 Houston
7 1 Phoenix
User2:
Id NationId Name
-----------------------
0 0 London
1 0 Manchester
2 1 New York
3 1 Boston
4 1 Houston
5 1 Phoenix
6 1 California
7 1 Chicago
I would prefer to have the City.Id, City.Name attributes to have a similar look across all the users databases.
So should I rather user guid's for the City.Id? Or does anyone know of an alternative method I can achieve this desired synchronisation.
Guids would certainly work for the problem you describe, however, what happens when two users add Boston to their databases? You'll end up with a large number of duplicates - especially in common cities.
Could you not pre-populate the database with city information?