How do you store sets in Cassandra?

Posted by Ben W on Stack Overflow See other posts from Stack Overflow or by Ben W
Published on 2010-04-20T06:12:28Z Indexed on 2010/04/20 6:43 UTC
Read the original article Hit count: 230

I'd like to convert this JSON to a data model in Cassandra, where each of the arrays is a set with no duplicates:

var data = { "data1": { "100": [1, 2, 3], "200": [3, 4] }, "data2": { "k1", [1], "k2", [4, 5] } }

I'd like to query like this: data["data1"]["100"] to retrieve the sets. Anyone know how you might model this in Cassandra? (The only thing I came up with was columns whose name was a set value and the value of the column was an empty string, but that felt wrong.)

It's not OK to serialize the sets as JSON or some other string, which would make this much easier.

Also, I should note that it's OK to split data1 and data2 into separate ColumnFamilies, it's not necessary that they're keys in the same one.

© Stack Overflow or respective owner

Related posts about cassandra

Related posts about database-design