“仅获取更新”设计
我的系统只需要从服务器获取更新。我如何设计我的数据库?有审计表或者有其他设计机制吗?我的计划是从我的设备发送更新 ID,并检索新的更新。如何真正落实这一点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来您正在寻找 SQL Server 复制。您可能需要查看 technet 文章与移动用户交换数据,其中描述了两种常见的模型,以及如何使用 SQL Server 来帮助您。
您可以选择使用审核表来滚动自己的表,但您仍然需要管理复制服务旨在帮助您解决的更新冲突问题。
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.
正如您提到的,一种方法是将已更改的内容写入审计或更改表。
如果您使用 SQLServer,还有一个时间戳列。它不是数据时间列 - 该名称具有误导性。相反,它是一个递增的数字,当触摸一行时,它会获取下一个数字。如果您获得最大时间戳,然后查询时间戳大于该长度的所有行,您将获得已更改/添加的行。
http://msdn.microsoft.com/en-我们/库/ms182776(v=sql.90).aspx
我特别警惕的一种方法是使用日期时间作为水印。它会发生变化,可以改变,并且不适合在算法中使用 - 特别是检测发生了什么变化。我见过系统在尝试依赖日期时间作为可靠的水印方法时失败了。
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.
几年前,我实现了这种设计。这很微不足道,但很有效。
据我了解,您希望像 Adobe 那样将更新推送到您的客户端。
在数据库中保留一个表(甚至不需要是一个表,您可以在 XML 中保留条目)。
当您的客户端应用程序加载时,检查服务器的版本,如果不匹配,则下载最新更新,然后更新客户端版本,否则正常加载您的客户端应用程序
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