I am developing an android application that has a sqlite database. I want to transfer data from a mySql database that hosted in a web server to the sqlite database. This data transferring will happen when a user install the application and when there is a change in the mysql database. To achieve this I hoped to uses a JSON web service. I know two ways to achieve this task using a JSON web service.
Use separate JSON responses to transfer data from each table of mysql database.
Use a single JSON responses to transfer data from all the tables of mysql database, in once.
My question is: what is the best way to achieve my task when consider the speed and reliability? (1 or 2)
Well, this question is primarily opinion based. anyway in my opinion you can create an extra table for recording changes from all the other tables in the database
ie. If you have 3 tables like
1.table 1
2.table 2
and
table 3
Add another table like changes_table
or something with fields like table_name
and isChanged
(boolean
). and listen for the isChanged
field and sync only that table because it is the best way to ensure data consistency and yields more performance (since transferring the whole database is obviously a heavy and slow process over network).