双时态 NoSQL 数据库有设计模式吗?

发布于 2024-09-28 19:07:04 字数 1539 浏览 1 评论 0原文

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

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

发布评论

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

评论(4

末蓝 2024-10-05 19:07:04

我不知道有任何 NoSQL 数据存储是专门为处理时态数据而设计的。
为了将有效时间段和交易时间段放入 Riak 中的数据中,您需要:

  1. 使用可以保存元数据的结构包装您的文档/值,例如:

    {
    元:{
    有效:[“2001-11-08”,“2001-11-09”],
    交易:["2011-01-29 10:27:00", "2011-01-29 10:28:00"]
    }
    有效负载:“这是我要存储的实际文档/值!”
    }

  2. 为每个文档创建一个“元文档”并使用 Riak Links 链接它们向上。

    我认为这更干净一些,但如果您需要经常检索这些时间,那么此方法可能太慢。

如果您想按时间检索文档,那么我认为 Riak(或我知道的任何其他键/值数据存储)不是合适的数据存储。 SQL 或可能某些 BigTable 系统可能是您唯一的好选择。

I don't know of any NoSQL datastore that are specifically designed to handle temporal data.
In order to put the valid and transaction time periods onto data in Riak you would need to either:

  1. Wrap your documents/values with a structure that can hold metadata like:

    {
    meta:{
    valid:["2001-11-08", "2001-11-09"],
    transaction:["2011-01-29 10:27:00", "2011-01-29 10:28:00"]
    }
    payload:"This is the actual document/value I want to store!"
    }

  2. Create a "meta-document" for each document and use Riak Links to link them up.

    I think this is a little bit cleaner but if you need to retrieve these times often then this method may be too slow.

If you want to retrieve documents by time then I don't think Riak (or any other key/value datastores that I know of) will be the right datastore to use. SQL or possibly some BigTable system may be your only good option.

述情 2024-10-05 19:07:04

我编写了一个基于 Mongodb 的小型双时态开源数据库层:

https://github.com/1123/bittemporaldb< /a>

存储 Scala 或 Java 对象时,对象被包装成具有双时元信息(有效时间、事务时间)的通用双时对象。随后它被序列化为 json 并以 BSON 形式存储在 MongoDB 中。

它透明地处理对象的时间和非时间更新。可以通过双时态上下文进行搜索。

用于双时态数据的面向文档的数据库是有益的,因为面向文档的存储减少了数据检索的连接数量。双时态上下文中的连接可能效率低下并且难以手动编码。

非常欢迎反馈、贡献和功能请求。

I have written a small bitemporal, open source database layer based on Mongodb:

https://github.com/1123/bitemporaldb

When storing Scala or Java objects, the object is wrapped into a generic bitemporal object with bitemporal meta-information (valid time, transaction time). Subsequently it is serialized to json and stored as BSON in MongoDB.

It handles temporal and non-temporal updates to objects transparently. Search by bitemporal context is possible.

Document-oriented databases for bitemporal data are beneficial, since document oriented storage reduces the number of joins for data retrieval. Joins in a bitemporal context can be inefficient and hard to code by hand.

Feedback, contribution and feature-requests are very welcome.

月亮坠入山谷 2024-10-05 19:07:04

为了支持双时态(或时态数据库模型),您需要酸性事务来执行适当的 DML,以在两个时间维度(有效/有效时间和事务/系统时间)上更新和插入记录。 查看有关时间建模的详细信息

例如,流行的 NoSQL 数据库(如 Cassandra、MongoDB、Couchbase)不具备 ACID 支持来执行支持双时态记录操作所需的必要记录更新/插入操作。对于时态和双时态数据库,记录绝不能重叠,并且当记录被后续有效/事务时间记录取代时,必须正确终止记录。

MarkLogic NoSQL 数据库声称支持双时态,但从未尝试过,也不是开源的。但是您可以通过使用 ACID 数据库来推出自己的解决方案,该数据库有效地充当有效/事务时间跟踪日志,然后使用 NoSQL 作为实际数据存储。请参阅此处方法的高级说明

To support a bitemporal (or temporal db model), you need acid transactions to perform the proper DML to update and insert records on two time dimensions (valid/effective time and transaction/system time). See for details on temporal modeling.

The popular NoSQL database like Cassandra, MongoDB, Couchbase, for example, don't have ACID support to perform the necessary record update/insert operations needed to support bitemporal record manipulation. With temporal and bitemporal databases records must never overlap and records must properly be terminated when superseded by succeeding valid/transaction time records.

MarkLogic NoSQL database claims support for bitemporal, but never tried it and is not open source. But you can roll your own solution by using ACID database that effectively functions as a valid/transaction time tracking journal and then use NoSQL for the actual data store. See high-level description of this approach here.

生生漫 2024-10-05 19:07:04

来自维基百科:

“双时态数据是时态数据库中使用的概念。它既表示数据的有效时间又表示数据的交易时间。
在数据库表中,双时态数据通常由四个额外的表列 StartVT 和 EndVT、StartTT 和 EndTT 表示。每个时间间隔在其下限处闭合,在其上限处开放。”

所以您不能将这四个值直接放入数据中?

From Wikipedia:

"Bitemporal data is a concept used in a temporal database. It denotes both the valid time and transaction time of the data.
In a database table bitemporal data is often represented by four extra table-columns StartVT and EndVT, StartTT and EndTT. Each time interval is closed at its lower bound, and open at its upper bound."

So you can't just put these four values onto your data?

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