“仅获取更新”设计

发布于 2024-12-13 10:09:32 字数 85 浏览 1 评论 0原文

我的系统只需要从服务器获取更新。我如何设计我的数据库?有审计表或者有其他设计机制吗?我的计划是从我的设备发送更新 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

奶茶白久 2024-12-20 10:09:32

听起来您正在寻找 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.

苦妄 2024-12-20 10:09:32

正如您提到的,一种方法是将已更改的内容写入审计或更改表。

如果您使用 SQLServer,还有一个时间戳列。它不是数据时间列 - 该名称具有误导性。相反,它是一个递增的数字,当触摸一行时,它会获取下一个数字。如果您获得最大时间戳,然后查询时间戳大于该长度的所有行,您将获得已更改/添加的行。

http://msdn.microsoft.com/en-我们/库/ms182776(v=sql.90).aspx

SQL Server 时间戳数据类型与时间或时间无关
日期。 SQL Server 时间戳是表示
数据修改发生的相对顺序
数据库。时间戳数据类型最初的实现是为了
支持SQL Server恢复算法。

我特别警惕的一种方法是使用日期时间作为水印。它会发生变化,可以改变,并且不适合在算法中使用 - 特别是检测发生了什么变化。我见过系统在尝试依赖日期时间作为可靠的水印方法时失败了。

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.

中性美 2024-12-20 10:09:32

几年前,我实现了这种设计。这很微不足道,但很有效。
据我了解,您希望像 Adob​​e 那样将更新推送到您的客户端。
在数据库中保留一个表(甚至不需要是一个表,您可以在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文