I want the two-way synchronization of my Android Android application database with the web application supported by the MySQL database. RESTful web application. Now I see two possible ways:
1. Synchronization directly with the MySQL database
This seems the easiest, but it looks like the web service storage mechanism should be abstracted from synchronization. It also looks like a potential security leak, as the MySQL server will need to listen globally, and not just on the same IP address of the web server. Just a gut feeling ...
2. Synchronization indirectly using the web service API
I could also indirectly associate PUTing / POSTING / DELETEing with the web services URI. This perfectly abstracts the data storage mechanism from synchronization, and the database server will only have to listen to the IP address of the web server.
But I will no longer use transactions for synchronization (the db scheme has a bunch of foreign keys), and I see no way to deal with failed inserts from primary collisions in this way.
Both have advantages and disadvantages. What is the way? How do professional products do it? Or is there another way that I have not thought about?
Any thoughts would be greatly appreciated :)
source
share