XML Database synchronization

kee nethery kee at kagi.com
Sat Dec 10 12:59:46 EST 2005


On Dec 7, 2005, at 1:16 PM, Joel Guillod wrote:

> Wanted functions:
> - To be able to synchronize each set (in order to have mirrors sets  
> of the xml documents);

This can be rather simple to accomplish. Add a last modified date  
stamp to each document. Have a master db with the up-to-date version  
of all documents. On a regular basis, maybe every minute or longer,  
look to see what data sets acquired a last modified date that is  
greater than the last stored last modified date. If a document has  
been modified, send it to the master server. Periodically, every so  
often, look to see if the master has any documents older than your  
last last modified date. If so, grab those and replace what you have  
internally.

Of course, all this postulates that your data does not change rapidly  
OR that you infrequently have two people modifying the same data set  
at the same time. If that is not a valid assumption, then you'll need  
to institute a locking mechanism. When someone wants to change  
something, make them press a button to indicate the desire to lock  
that record. Grab the updates, send a record lock (with a time stamp)  
to the master, and then give them some number of minutes to make the  
desired changes. If the changes are not made within the desired  
amount of time, have the master unlock the record and have the client  
not save the changes (unless no one else has made a change to the  
record which you can tell by the timestamp at the master).

But the key to it all is to date time stamp everything. Also, you are  
using a date time stamp but keep in mind that clocks can get out of  
sync so treat the date timestamp as an incrementing marker, not as  
the actual time. Thus, when you update to the master, the master  
creates the timestamp and that is what is used throughout the system.

Kee Nethery



More information about the use-livecode mailing list