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?
Share
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.