HBase 一对多“关系”贮存
我正在考虑在 HBase 中实现一对多关系的最佳方法。
假设一个账户有很多交易。是否最好
a) 将列添加到 ACCOUNT 表上的 transactions: 列族,即 transactions:1:amount, transactions:2:amount
b) 仅将与帐户相关的每个 TRANSACTION 的键存储在transactions:ACCOUNT 的列族,并查找在单独的 TRANSACTION 表上找到的每个交易?
I'm pondering the best way to implement a one to many relationship in HBase.
Say an ACCOUNT has many TRANSACTION(s). Is it better to
a) Add columns to a transactions: column family on the ACCOUNT table, i.e. transactions:1:amount, transactions:2:amount
b) Only store the key(s) of each TRANSACTION relating to an account in in the transactions: column family of ACCOUNT, and do a lookup of each transaction found on a separate TRANSACTION table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一般来说,选项 a 是更好的方法。
这使您可以轻松地一次请求一个帐户的所有交易。对于每笔交易,不需要额外的查找。
在某些用例中,选项 b 可能适用,例如对所有事务频繁运行查询。
Generally, option a, is the better approach.
This allows you to easily request all the transactions for an account at once. No additional lookup is needed, for each transaction.
There are use cases where option b may be appropriate, such as frequently running queries on all of the transactions.
我想如果帐户需要跟踪的唯一数据项是金额,那么选项 (a) 就可以了。但是,如果您需要捕获许多其他数据项,我认为我们必须使用选项 (b),即使它的效率低于 (a)
I guess option (a) would be ok if the only data item that needs to be tracked for Account, is the amount. However, if you need to capture many other data items, I think we'll have to go with option (b) even though it is less efficient than (a)
拥有单个列值并使用 $ 和 # 等分隔符怎么样?下面是示例数据:
现在您可以使用 $ 和 # 分隔符来获取值并使用字符串数组来处理数据。
How about having a single column value and use a separator like $ and #. Below is the sample data:
Now you can use $ and # separators to fetch the values and use String arrays to process the data.