修订:算法和数据结构 [英] Revisions: algorithm and data structure

查看:180
本文介绍了修订:算法和数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用修订版来构建和处理数据的想法。
例如,我有一个对象数据库(例如汽车)。每个对象都有一些属性,可以是任意的,所以没有一个设置模式来描述这些对象。这些对象可能保存为键值对。

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!

推荐答案

有一个可能是有一个对象和属性表(你可能已经有)。
创建包含
ID的对象表ID ObjectId PropertyId值Date_Added / version_number(根据您的选择,如果要使用时间戳或序列列)

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.

当要获取最新对象属性的快照时,需要对由date_added / version number排序的属性执行DISTINCT查询。
对于给定的属性检查历史也很简单。

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.

我希望这有助于

这篇关于修订:算法和数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆