7
I have an application in which I have a database using Sqlite and an external service using Mysql. Basically it’s a task application, where I can create a task in mode offline. When the user has internet he already automatically send to Mysql.
I have to do the synchronisation treatment and I’m having trouble solving it.
USER 1
- Create a task
- Synchronize the task with external bank
USER 2
- Check for tasks in the external bank
- Synchronize tasks
Problem
After user 2 (USER 2) completes his task, he must make the sync again with Mysql, and successively user 1 (USER 1) has to receive also this update in its database.
In the most simplified way possible, the tables would be:
tbl_task no Sqlite
- id_internal------------( unico identifier for internal control)
- task-------------( task name )
- status---------------( status of completion of the pending/completed task)
- id_usuario-------------( user who will perform the task )
- id_author---------------( task creator user )
- id_external--------------( external identifier if already syphonized )
tbl_task in Mysql
- id----------------------( unico identifier )
- task-------------( task name )
- status---------------( status of completion of the pending/completed task)
- id_usuario-------------( user who will perform the task )
- id_author---------------( task creator user )
My initial idea would be to create a column in the table with the name SYNC
, in which I would have control whether it was synchronized or not. However USER 2 complete a task, such as the USER 1 verify that conclusion?
Instead of recording only one SYNC field, why don’t you also use a last update of the kind TIMESTAMP ? Thus, when the user updates the task data, he saves that data in the database. Thus, when synchronizing the data, if the locally stored task has a lower TIMESTAMP than the external database, it is because it is outdated, therefore it needs to be synchronized.
– regmoraes