HBase一对多的“关系"存储 [英] HBase one to many 'relationship' storage

查看:215
本文介绍了HBase一对多的“关系"存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在HBase中实现一对多关系的最佳方法.

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)在交易中添加列:ACCOUNT表上的列族,即交易:1:金额,交易:2:金额

a) Add columns to a transactions: column family on the ACCOUNT table, i.e. transactions:1:amount, transactions:2:amount

b)仅将与帐户相关的每个交易的关键字存储在交易中:ACCOUNT列族,并在单独的交易表中查找每个交易吗?

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?

推荐答案

通常,选项a是更好的方法.

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.

在某些情况下,选项b可能适用,例如对所有事务频繁运行的查询.

There are use cases where option b may be appropriate, such as frequently running queries on all of the transactions.

这篇关于HBase一对多的“关系"存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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