【发布时间】:2016-06-07 18:07:33
【问题描述】:
我的查询是获取特定学生在特定考试中的分数。对于 Cassandra 表设计,选项 1,
CREATE TABLE student_score (
student_name text,
exam_name text,
score int,
exam_time timeuuid
PRIMARY KEY (exam_name,student_name)
)
WITH CLUSTERING ORDER BY (student_name DESC);
exam_name 将是分区键,所有学生都将在宽行中。
选项 2,
CREATE TABLE student_score (
student_name text,
exam_name text,
score int,
exam_time timeuuid
PRIMARY KEY ((exam_name,student_name))
)
exam_name 和 student_name 共同构成分区键,因此没有宽行。
选项 1 是标准方式。但是选项2有什么问题?
【问题讨论】: