The Situation: I have a database and a web app that interact to display and update tables of scientific data. My task is to construct a mobile application that will allow users to
- Authenticate and Identify Themselves Offline for Tracking Purposes (using predefined but dynamic user-accounts and permissions stored in the cache)
- Download Identification Data for Work in the Field (with internet access)
- Make and Store Observations in the Field (without internet access)
- Synchronize Observations into an Online Database at a later time
The Question: What is the best way to go about authenticating/downloading/storing/uploading the necessary data to administer such an application independent of consistent internet access? If two people adjust the same reading, and one update happens in between syncs, how do I track which tables and values have been altered, and prevent the changes from being lost?
The Current Train of Thought: My current tentative strategy on collision control to maintain a "Sync" table that stores JSON objects representing every online database transaction stored in sessionStorage and have the app continuously verifying its sync prior to uploading data, and checking this object for potential collisions on updates to specific primary keys. I would like to be able to lock tuples when they are in an editing stage, but that seems impossible with inconsistent internet access.
Sorry if this is a bit of a newb question, I'm new to the whole mobile app development thing...
tl;dr How do I prevent asynchronous changes to the database from mobile apps that go on and offline from overwriting/colliding with another individual's changes to the same database? And how do I authenticate users w/o a network connection?