修订:算法和数据结构

发布于 2024-08-28 18:35:12 字数 286 浏览 2 评论 0原文

我需要通过修订来构建和处理数据的想法。 例如,我有一个对象数据库(例如汽车)。每个对象都有许多属性,这些属性可以是任意的,因此没有一个固定的模式来描述这些对象。这些对象可能保存为键值对。

现在我需要更改对象的属性。我不想完全重写它 - 我希望能够返回并查看这些属性的更改历史记录,这就是为什么我想添加新属性并保留旧属性(所以我猜时间戳可以完成这项工作告诉哪个属性是最新的)。

同时,我希望能够快速获取有关任何对象的信息,并且仅包含每个属性的最新版本。

有什么想法最好的方法是什么?至少请指出我正确的方向。谢谢!

I need ideas for structuring and processing data with revisions.
For example, I have a database of objects (e.g. cars). Each object has a number of properties, which can be arbitrary, so there's no a set schema to describe these objects. These objects are probably saved as key-value pairs.

Now I need to change property of an object. I don't want to completely rewrite it - I want to be able to go back and see history of changes to these properties, that's why I want to add new property and keep the old one (so I guess a timestamp would do the job of telling which property is the latest).

At the same time I want to be able to get info about any object in a snap, with only latest versions of each of the properties.

Any ideas what would be the best approach? At least please point me in the right direction. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

々眼睛长脚气 2024-09-04 18:35:12

一种可能性是拥有一个对象和属性表(您可能已经拥有)。
创建包含以下内容的关联表
ID ObjectId PropertyId Value Date_Added/version_number(根据您的选择,如果您想使用时间戳或序列列)

根据您的问题,您将始终添加到关联表并且从不更新它。

当您想要获取最新对象属性的快照时,您需要对按添加日期/版本号排序的属性执行 DISTINCT 查询。
对于给定的属性,检查历史记录也很简单。

我希望这有帮助

One possibility is to have a object and property table (which you may have already).
The create the association table containing
ID ObjectId PropertyId Value Date_Added/version_number (as per your choice if you want to use timestamp or sequence column)

As per your problem you would always add to association table and never update it.

When you want to get a snapshot of latest object properties, you need to do a DISTINCT query for properties ordered by date_added/version number.
For a given property checking history is straightforward as well.

I hope this helps

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