Tuesday, June 1, 2010

SQL Lite replication engine for HTML5(iPhone & Domino Data)

I have been working on ITANA to give it the ability to edit and add and delete records while offline. To do this i am using SQL lite as the data store for the iPhone or HTML5 enabled device. Then i "Replicate" it to the notes server via xhr requests.

Please help me with my logic, does this outline work? Am i missing something? What might be better?

Sql lite Replication engine

1. Get all documents from notes db and unids

2. For each notes doc check if local record exist

3. If local record exists check the last updated time of local record
and notes doc, if server doc is newer update local record, if the
local record is newer update the server record.

Check the delete status on the local record, if set to delete, delete
the server record and remove the local record.

4. If local record does not exist create one

5. Get all local records and unids.

6. Check if they exist on server, if local record has unid = new doc,
create doc on server and update the local record with real unid, else
delete the local record because it has been deleted on the server.


Mark Hughes said...

David Leedy suggested i add a last replicated time stamp and check against that to see if the doc has been updated since the last replication, if it has not skip it. That should help in scaling performance.

Paul T. Calhoun said...

What is the total size of the local data storage? Would somehow need to determine if all documents could be stored locally or limit it to the most recent X number of documents.

Mark Hughes said...

Local Data storage will give you 5Mb, in my example i would not run into this since i am just getting unfinished tasks, unless someone is really really for behind.

I wonder how to calculate how much space that would take?

Peter said...

I was also thinking the last replication date/time would help speed things up. How would you handle a replication conflict, where both server and local copy have been updated since the last replication? Either just take the last updated one, or perhaps ask the user?

Mark Hughes said...

@peter i was thinking about a server or client always wins setting, defaulted to the server. I have seen this before, it might be hard to prompt the user for which one to use on a mobile device.

Peter said...

agreed Mark, might be hard to ask about each of them. Configurable for either server or client wins would be useful.

Post a Comment