Cassandra DataModel设计,复合键与超级列

时间:2014-11-27 17:20:10

标签: cassandra composite-key datamodel super-columns

在cassandra中设计数据模型时。我在设计以下场景时遇到困难。

Like One API / Webservice可以有多个参数(输入/输出)。我也不知道参数计数及其列名。

如何设计其cassandra数据模型。我知道超级列不好用,替代的好解决方案是使用复合键。但是对于我的场景,我没有固定列名称和计数我可以指定为复合键。

请参阅下面我要建模的图片

enter image description here

其次如何编写其create table语句,以便我可以将参数名称指定为列名。

如果有任何不清楚的地方,请告诉我。

谢谢,

1 个答案:

答案 0 :(得分:1)

为什么不使用地图?

http://www.datastax.com/documentation/cql/3.1/cql/cql_using/use_map_t.html

create table foo(
   name text,
   owner text,
   version text,
   params map<text, text>,
   primary key (name, owner, version)
);

如果你是2.1,你可以在地图键/值上创建二级索引,如果需要,可以提供更大的灵活性。