gpt4 book ai didi

java - 使用java将Mysql数据库转为Nosql hbase

转载 作者:行者123 更新时间:2023-11-29 10:43:22 24 4
gpt4 key购买 nike

我想将这种关系转换为“1对多”员工可以有0个或多个订单到Nosql hbase Mysql data base

最佳答案

如果 HBase 检索一名员工的所有订单,您可以使用以下行键结构:

RowRey = ShardKey + EmployeeID + OrderID

其中 ShardKey 是(EmployeeID % 区域数量)。这允许在区域服务器之间有效地分发数据以避免热点。您可以有两个列族。在第一个列族中,行的列可以与订单表中的列相同。第二列中的内容与员工表中的相同。由于这些数据具有不同的更新率,建议将它们分开保存。

A column family is an HBase-specific concept that you will not find in other RDBMS applications. For the same region, different column families will store the data into different files and can be configured differently. Data with the same access pattern and the same format should be grouped into the same column family. As an example regarding the format, if you need to store a lot of textual metadata information for customer profiles in addition to image files for each customer’s profile photo, you might want to store them into two different column families: one compressed (where all the textual information will be stored), and one not compressed (where the image files will be stored). As an example regarding the access pattern, if some information is mostly read and almost never written, and some is mostly written and almost never read, you might want to separate them into two different column families. If the different columns you want to store have a similar format and access pattern, regroup them within the same column family.

但为了简单起见,您可以使用以下行键将员工数据保存在单独的表中

RowRey = ShardKey + EmployeeID

Architecting HBase Applications

关于java - 使用java将Mysql数据库转为Nosql hbase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45052637/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com