Thursday, March 29, 2012

Distributed data synchronization - Comparing timestamp

Hello,

I am designing a distributed application where a central SQL Server 2005 database will need to be synchronized with remote SQLExpress databases via a WebService. Data can be edited at the cental db (by our connected applications) or on the local SQLExpress dbs running on the users machines (by this disconnected application).

Now, how can I use the timestamp column to determine the most recent update. The most recent update to me is not the user that most recently invoked the syncing WebService, but the most recent time when the change was made to the data locally vs the change time at the central server. Because a user could make a change on his laptop on Monday but not synchronize it till Friday. I dont want the Mon data to overwrite data of Tues-Fri being overwritten simply based on assumption that a late sync is infact the most recent change.

The initial data will be downloaded to the local SQLExpress db via the WebService so the timestamp data in the table will come along with it.

When a user modifies data in this disconnected SQLExpress db, can that be compared to modifications on the central db using timestamps to determine if the users data being synced is older or newer than the data on the server? I understand timestamps are incremental values, but are they still sensitive to the users timezone since the central server will be a diff timezone then the user.

Timestamps are instance-level unique numbers. So you can't really compare those across instances. Why don't you use merge replication for instance? It is designed to solve problems like these. If you assistance on the replicaiton part you should post in the replication forum.|||

For ISVs that are building installable components, replication isn't too attractive. The components are meant to be quickly deployable whereas replication requires configuration to be done to create the publishers, distributers, etc.

So, basically, I would have to write a home-grown solution for conflict resolution?

Does anyone know how Microsoft is handling conflict resolution for the remote synchronization in its Project Elixir, which I believe also synchonizes disconnected data caches using webservices?

|||Then you will have to use a combination of binary_checksum or checksum along with comparison of columns or generate hash for each row using hashbytes function. You can compare rows efficiently this way and then perform the conflict resolution. This of course is no easy matter since each technique has it's own pros and cons.|||

hi,

Can I know is there anyway to compare 2 timestamp in .NET?

For eg. I got 2 timestamp, I want to know which 1 is the most recent changed.

Thanks.

No comments:

Post a Comment