0

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,

Usman
  • 105
  • 3
  • 10

1 Answers1

1

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.

ashic
  • 5,932
  • 3
  • 28
  • 47
  • Thanks, my requirement was secondary indexes and yes in 2.1 its supported. Could you please confirm me the size of collection, as it is 64K for one item right ? And total 64K items items in collection (http://www.datastax.com/documentation/cql/3.0/cql/cql_using/use_collections_c.html), means 64k * 64K for a collection maximum ? – Usman Nov 27 '14 at 19:29
  • 1
    I think it'd be 64k keys for a map. For more, you can use multiple maps in a row. BUT don't store many items in collections...that's not what they're meant for. Remember, large partitions will affect performance. Theoretical limits aren't really practical limits. – ashic Nov 27 '14 at 20:57