1

我正在寻找一些关于 cassandra 数据建模的输入,以获取时间线类型的功能。为了存储时间线的数据,我打算timeuuid在 cassandra 中使用并将其作为集群键。这将有助于对数据进行排序。但是同样的数据是可以更新的,我需要把更新后的timeuuid对应的数据存储起来,这样就可以在时间轴上上推。这涉及获取前一个 data-timeuuid 行,将其删除并插入新行。但似乎表现不佳。如何处理同一列上的排序和更新(在我的情况下为 timeuuid)以实现时间线功能。

4

1 回答 1

0

I suggest this schema to you :

CREATE TABLE timeline_idx {
    timeline_key text,
    time timeuuid,
    content_key text,
    PRIMARY KEY ((partition_key), time)
}

CREATE TABLE timeline_content {
    content_key text,
    content blob,
    PRIMARY KEY (content_key)
}

Timeline_idx is used to give you the content keys ordered as a timeline. Then you can retrieve the content in a second table called timeline_content. It is not ordered and there is no clustering key. You can update your content without knowing its timeuuid. I choose text type for timeline_key and content_key but you can choose whatever you want as long as it identifies timelines and contents uniquely.

于 2016-01-04T17:26:14.957 回答