My system needs to get only the updates from the server. How do I design my database? Have an audit table or is there any other design mechanism? What I'm planning is to send an update id from my device, and retrieve the new updates. How to really implement this?
'Getting only updates' Design
89 views Asked by Sivaneasharajah Lushanthan AtThere are 3 answers
It sounds like you're looking for SQL Server Replication. You might want to look at the technet article Exchanging Data with Mobile Users which describes two common models, and how you can use SQL server to help you.
You could choose to roll your own with audit tables but you'll still need to manage the problems of update collision that the replication services are intended to help you solve.
Years ago, I implemented this kind of design. It was very trivial but it worked. As far as I understand, you want to push update to your client like Adobe does. Keep a table in database(it even need not be a table, you can keep entry in XML). When your client application loads, check the version against server, if mismatch then download the latest update and then update the client version else normally load your client application
Writing to an audit or change table what has changed is one approach as you have mentioned.
If you're using SQLServer, there's also a timestamp column. It's not a datatime column - the name is mis-leading. Instead, it is an incrementing number and when a row is touched, it gets the next number. If you get max timestamp and then later, query all rows with timestamp greater than that long, you'll get the rows that were changed/added.
http://msdn.microsoft.com/en-us/library/ms182776(v=sql.90).aspx
One approach I would specifically be wary of is using datetime as the watermark. It shifts, can change and is not good for use in an algorithm - especially to detect what has changed. I've seen systems fall down trying to rely on datetime as a reliable watermarking approach.