I'm actually developing a synchronization tool in vb.net, I have two database that have on each table records field GUID, this field help to have the same PK on both database. On each record there is also a field called lastUpdated, this field have a milliseconds value, so prevent two user to update the record in the same time. My question is, how I can compare the records of the same table from different db? For example:
ONLINE_DATABASE
TABLE_1
| ID | GUID | NAME | LASTUPDATED |
| 5 | 054ba092-b476-47ed-810b-32868cc95fb| John | 06-01-2016 17:01:12.472438 |
CLIENT_DATABASE
TABLE_1
| ID | GUID | NAME | LASTUPDATED |
| 9 | 054ba092-b476-47ed-810b-32868cc95fb| Jack | 06-01-2016 18:01:12.472438 |
How you can see I've update the record from client application, so I need to apply the same change to online database. Now I've a thousand records to check in about ten tables. So my question is, how I can made a system that do this? Actually I tough to read each row with a MySqlCommand reader but I also think that this procedure is slow… Suggest?
NOTICE THAT: the table have the same name in both db
Best Answer
If the GUID is the absolute truth about what is supposed to match, then the GUID must be the
PRIMARY KEY
. Get rid ofid
.If you want semi-automated "conflict resolution based on time", you want MySQL's NDB Cluster.