Reputation: 11740
I am working on my first project with the Cassandra database, and I'm trying to wrap my head around the data modelling. I am attempting to come up with a ColumnFamily definition that allows me to store some data that could be modelled (in C#) like this:
class the_data
{
public string prop_1;
public string prop_2;
public Dictionary<string, Dictionary<string, List<string>>> other_data;
}
Now, the other_data can have its keys combined to create something like this:
public Dictionary<string, List<string>> other_data;
(where the key in this dictionary would be the combination of the two keys in the previous version).
I believe that I could model just this part of the data in Cassandra using a composite column, like so:
CREATE TABLE some_data
{
row_key text,
other_data_outer_key text,
other_data_inner_key text,
other_data_value text,
PRIMARY KEY (row_key, other_data_outer_key, other_data_inner_key)
};
What I don't understand, however (or maybe it isn't possible), is how to have the composite column (because other_data_outer_key and other_data_inner_key become parts of the column name), as well as other columns that are NOT composite columns, nor duplicated for every combination of keys.
I'd like something like this:
CREATE TABLE some_data
{
row_key text, <--- row key (partition key?)
prop_1 text, <--- just a normal column (one per row) #1
prop_2 text, <--- just a normal column (one per row) #2
other_data_outer_key text, <--- composite column name part 1
other_data_inner_key text, <--- composite column name part 2
other_data_value text, <--- composite column value
PRIMARY KEY (row_key, other_data_outer_key, other_data_inner_key)
};
Is this possible? How can I accomplish this?
Upvotes: 1
Views: 155
Reputation: 7365
Have a look at static columns: http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/refStaticCol.html
This provides a way to store properties per partition in tables that have clustering columns.
Upvotes: 1