gpt4 book ai didi

sql - HBase 中的高级查询

转载 作者:可可西里 更新时间:2023-11-01 14:13:55 25 4
gpt4 key购买 nike

给定以下 HBase 模式场景 ( from the official FAQ )...

How would you design an Hbase table for many-to-many association between two entities, for example Student and Course?

I would define two tables:

Student: student id student data (name, address, ...) courses (use course ids as column qualifiers here)

Course: course id course data (name, syllabus, ...) students (use student ids as column qualifiers here)

This schema gives you fast access to the queries, show all classes for a student (student table, courses family), or all students for a class (courses table, students family).

您将如何满足以下要求:“给我至少共享两门共同类(class)的所有学生”?您能否在 HBase 中构建一个将返回该集合的“查询”,或者您是否必须检索所有相关数据并在代码中自行处理?

最佳答案

所描述的查询更适合关系数据库。但是,您可以通过预先计算结果来快速回答查询。例如,您可能有一个表,其中键是共同类(class)的数量,而单元格是具有许多共同类(class)的个别学生。

您可以对此使用变体来回答诸如“哪些学生在 X 类和 Y 类”之类的问题:将类(class)用作 key 的一部分(按字母顺序排列,或至少保持一致),再次,每个列是学生。

关于sql - HBase 中的高级查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1436076/

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