I want to sync it both ways between my android SQLite and server using a sync adapter.
The android application can perform all CRUD operations and the website can do the same thing.
The website will use the server database. Currently I use PostgreSQL but it can be changed.
The mobile app will use its own local database.
How can I sync them? The big problem is with the primary key.
-
One of the ideas is to use
uuidas primary keys but there are performance issues, because as you can see there are some join I need to perform to get from the user to other tables. -
Another idea is to leave the
primary keyasauto increment integersand useuuidcolumns only for syncing. But this adds a new table column for eachprimaryandforeign keyin each table. -
Last one is to use a
compound keyas primary. This one will include 3 columnsuser_id,id(origin database id) anddevice_id(website / mobile app etc). And the same thing for each foreign key.
Are there any better solutions ? If no which of mine solutions sould I use ?
How does Gmail, Keep, Dropbox or other applications performs this kind of task?
Thank you.
Aucun commentaire:
Enregistrer un commentaire