Question

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?

Was it helpful?

Solution

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

The SQL Server timestamp data type has nothing to do with times or dates. SQL Server timestamps are binary numbers that indicate the relative sequence in which data modifications took place in a database. The timestamp data type was originally implemented to support the SQL Server recovery algorithms.

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top