I am new to cassandra and find it a bit difficult to understand in creating a simple keyspace with some structure that I am thinking of. I created a keyspace called “acquisition” using the cassandra CLI.
Using Cassandra-CLI how can I create the following for the “acquisition” keyspace –
TagNo // This is the super column
{
ID // This is the column family
{
// here we shall have lots of entries. (Rows)
user1: {rate, distance, capacity}
user2: {rate, distance, capacity}
}
}
Rate distance and capacity can be stored as either strings or doubles. But does not really matter at the moment.
I am not sure how on to do this using the CLI. So please help
create keyspace.
create super column family.
create column family TagNo with column_type = 'Super' and comparator = 'UTF8Type' and subcomparator = 'UTF8Type' and default_validation_class = 'UTF8Type' and column_metadata = [{ column_name : rate, validation_class : AsciiType}, { column_name : 'distance', validation_class : AsciiType}, {column_name : 'capacity', validation_class : AsciiType}];set a few example values to the TagNo super column family.
[default@acquisition] set TagNo[utf8('ID')]['user1']['rate'] = '10'; Value inserted. Elapsed time: 2 msec(s). [default@acquisition] set TagNo[utf8('ID')]['user1']['distance'] = '100'; Value inserted. Elapsed time: 2 msec(s). [default@acquisition] set TagNo[utf8('ID')]['user1']['capacity'] = '50'; Value inserted. Elapsed time: 2 msec(s). [default@acquisition] set TagNo[utf8('ID')]['user2']['capacity'] = '50'; Value inserted. Elapsed time: 2 msec(s). [default@acquisition] set TagNo[utf8('ID')]['user2']['rate'] = '20'; Value inserted. Elapsed time: 1 msec(s). [default@acquisition] set TagNo[utf8('ID')]['user2']['distance'] = '100'; Value inserted. Elapsed time: 2 msec(s).show values..
[default@acquisition] get TagNo[utf8('ID')]; => (super_column=user1, (column=capacity, value=50, timestamp=1331605812776000) (column=distance, value=100, timestamp=1331605805912000) (column=rate, value=10, timestamp=1331605780216000)) => (super_column=user2, (column=capacity, value=50, timestamp=1331605816568000) (column=distance, value=100, timestamp=1331605846008000) (column=rate, value=20, timestamp=1331605821608000)) Returned 2 results. Elapsed time: 3 msec(s).