鉴于以下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).
您如何满足这一要求:“给我所有共享至少两门共同课程的学生”?您可以在HBase中构建一个返回该集合的“查询”,还是必须检索所有相关数据并在代码中自行处理?
解决方法
所描述的查询更适合于关系数据库.但是,您可以通过预先计算结果来快速回答查询.例如,您可能有一个表,其中键是共同的类的数量,并且单元格是具有共同键的许多类的单个学生.
你可以使用一个变体来回答诸如“哪个学生在X班和Y班”中这样的问题:将这些类用作键的部分(按字母顺序排列,或者至少是一致的),同样,每列都是一个学生. (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|