First of all in this question i am not making any complaints with any DB its just something i dont know and need to improve myself.
I have developed one app which contains coredata and it has almost 5 to 6 tables for eg jobs,employees etc etc .. ok now few points about coredata.
- Coredata automatically manages primary key management we dont need to create the PK in every table
- Myserver contains primary key for e.g. job_id , emp_id which is auto increment Now in my app i have to sync my data with server, well when i add any entry in my table the respective fields job or emp ids are going to be zero as expected i cant create my own value in this fields.
So now when in every 30 minutes i have to create one JSON which contains Array of table which should get latest DB records that user have performed during these 30 minutes like add update delete so i need one kind of mechanism where i can sync data with my server and server also identify that this row need to be added or updated or deleted.
I have tried few following possibility but still i am not getting success with perfection
- I have created 3 fields createdtimestamp,updatedtimestamp and deletedtimestamp so when user add one entry first time it will be createdtimestamp of device time becuse app can runn offline.
- So in respective actions i do update other timestamps if user update any record or delete any record.but in order to get updated with server we must have to get latest entries with the server timestamp but in this case if iser timestamp are not matched with server then this case failes.
So i need suggestions from this community. THANKS.