If I copy, I don't want to transfer EVERY record to the server each time I sync, because that would be a waste of bandwidth. What is the best way to copy only those records that have changed to the server?
David -----Original Message----- From: Simon Slavin Sent: Wednesday, October 06, 2010 7:18 AM To: General Discussion of SQLite Database Subject: Re: [sqlite] SQLite database sync On 6 Oct 2010, at 1:29pm, David Haymond wrote: > I am completely new to SQLite (and SQL in general), and I am currently > working on an iPhone app that uses the embedded SQLite engine to cache > offline data. What is the best way to implement synchronization > capabilities (change tracking, state tracking, etc.) in a separate table > (such as meta), so that the app can sync to the server? > > My database contains two tables: locations and trips. trips is the child > of locations. Does it actually have to synchronise ? In other words, are changes made to both copies, or only to the copy on the iPhone ? If changes are made to only one copy, you can just copy that copy (if you see what I mean). If changes are made to both copies, you're in for a world of hurt because you really need to separate out intentional changes from the changes actually made. One way to do it is to keep a log of the operations executed since the last synch. For example you could make another table 'changelog': timestamp operation 2398479 INSERT INTO locations ... 2402372 UPDATE trips ... To synchronise you just execute the log, in timestamp order, on all the other copies. This does not work properly under all circumstances because UPDATE commands can interfere with one-another, but in a simple database it should work fine. To do things properly you need to maintain a separate unchanged model, synch it with all the satellites, then copy it to all the satellites. It's complicated and requires lots of bytes moved about. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users