Yes, I know that there are several issues related to synchronizing with iPhone and web databases, but none of them helped me. I also did a lot for googling, but rarely came across information about two-way synchronization. Maybe I just used the wrong keywords.
I am creating an application right now and I came up with the idea of adding two synchronizations to my application and my web service. My first thought was that it would be ridiculously easy, but it turned out that it was not so simple. I found a couple of problems and some solutions to my problems, but I would like to hear from you guys if these souls will create other problems or if these solutions will be good or bad.
The idea of my application helps me synchronize my notes, which I will take with my iPhone at work or at home using a web application. These two ends should always be synchronized, because I do not know which device (iPhone or computer) I will use to edit, edit or just read my notes.
What I have on both sides:
For my web service (and web application) I will use rails and I think mysql is on the DB side. On iPhone, I will use SQLite DB with Objective-C wrapper (FMDB). Both will exchange data via JSON (using the JSON framework on the iPhone side).
My ideas so far:
The primary key must be unique on both sides.
I will use the UUID as the primary key. I think this is a unique solution on both sides and it will not make any duplicates (at least I hope).
Changes for data changes
Each change will be saved as a revision using the SHA1 key, which I will create from date + note data . The audit object also includes the following information:
- the date
- which notes that the object belongs to this version
- Changes made on which device?
- what sings? (usually I'm not sure if I include this information).
My "solution" so far I will track every modification (create, update, delete) in the histroy table with revisions on both sides. On the iPhone side, I first update my history table from the web database, and then commit my changes to the web database. That should work, right?
This doesn't sound so bad to me, but my question here is how can I handle conflicts? I do not want to disturb the user with messages on how to deal with conflicts.
Overview of my questions:
- Is my “decision” good or bad? What should I change to make it better?
- How can I handle change conflicts so that the user does not notice them?
- Do you have any resources that I could read about a two-way approach?
EDIT:
Thank you all for your answers. Now I know that I am not alone with this “problem”, and there is no simple and suitable solution for all applications. I assume that so far I am well versed in my ideas or decisions, and I will try to come up with synchronization rules.
My idea is still: I will develop it as simple as possible and I will use it for my needs. Solve the problems that I discovered when using and syncing. After that, I will invite my friends to check and solve the problems that they have. I think that this way I can find real rules for synchronizing my data with the Web, because I see what people really do and where the problems are.
What do you think?