Cassandra DataModel Designing, Composite Key vs Super Column

128 views Asked by At

while designing the datamodel in cassandra. I am stuck while designing the below scenario.

Like One API/Webservice can have multiple parameters(input/output). I don't know the parameters count and its column name as well.

How to design its cassandra datamodel. I am aware that supercolumns are not good to use and alternative good solution is using composite keys. But for my scenario I don't have fixed columns names and count that I can specify as composite keys.

Please see the pic below which I want to model

enter image description here

Secondly how to write its create table statement so that I can specify parameter name as column name.

Please let me know if anything is unclear.

Thanks,

1

There are 1 answers

2
ashic On BEST ANSWER

Why not use a map?

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)
);

If you're one 2.1, you can create secondary indexes on the map keys / values, which caters to more flexibility if needed.