分层、有序、键值存储?
我正在寻找一个具有以下功能的数据库系统:
- 分层(多维)键
- 每个维度的键排序
因此,如果我的键类似于 App >用户> Item
我可以运行这样的查询:“该用户的下一个项目是什么?”或者“这个应用程序的下一个用户是什么?”
我基本上想要一棵多维树。我发现了 GTM,并且想知道是否还有其他类似的产品。
I'm looking for a database system which has the following capabilities:
- Hierarchical (multi-dimensional) keys
- An ordering of keys at each dimension
So if my key is like App > User > Item
I can run a query like: "what is the next item for this user?" Or "What is the next user for this app?"
I basically want a multi-dimensional tree. I found GTM, and am wondering if there are any other products like this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
鉴于您的要求,我想说使用多个嵌套 b 树是一个很好的解决方案。
您可能还需要考虑使用单个 b 树和一些巧妙的密钥编码,以便对于密钥(路径)中的每个段都有一个保留的最小令牌和最大令牌。
拥有这样的键将允许您使用标准的 B 树访问方法来进行查询。
“该用户的下一个项目是什么”将是:找到大于
App > 的键。用户>项目> **MAX**
并且,“此应用程序的下一个用户是什么”将是:找到大于
App > 的键。用户> **MAX**
对于第二种方法(键编码而不是嵌套树),任何基于 B 树的 No-SQL 解决方案就足够了。选择哪一种取决于您的编程环境和您可能有的其他要求。
Given your requirements I'd say that using multiple nested b-trees is a good solution.
You may also want to consider using a single b-tree and some clever key encoding so that for each segment in the key (path) there is a reserved min-token and max-token.
Having such a key would allow you to use standard b-tree access methods for your queries.
"what is the next item for this user" would be: find the key greater than
App > User > Item > **MAX**
and, "what is the next user for this app" would be: find the key greater than
App > User > **MAX**
For the second approach (key encoding instead of nested trees) any b-tree based No-SQL solution would suffice. Which one to choose depends on you programming environment and other requirements you might have.
我以前遇到过这个问题;我使用了一个名为
parent_id
的列,它使用父级的 id 来链接子级。在一个简单的示例中,我们将维度“Item”的id
设置为5
。因此,parent_id
为5
的每一行都将位于“Item”下。然后,您可以使用foreach
将所有父级链接起来。I've come across this problem before; I used a column called
parent_id
which used the id of, well, the parent to link the children. In a simple example, we set theid
to5
for the dimension "Item". Therefore every row with aparent_id
of5
will come under "Item". You can then use aforeach
to link all the parents up.