I am creating a cassandra table(columnfamily) and want to confirm how my rows are alligned.
DROP TABLE Message;
CREATE TABLE Message ( category_id varchar , msg_id varchar , msg blob , PRIMARY KEY ( category_id, msg_id ) );
I am expecting the above table to store the 'msg' column in a wide row for identical ?category_id".
Desired table structure:
category1 -> {msgid1: msg} | {msgid2: msg} | {msgid3: msg}
category2-> {msgid1: msg} | {msgid2: msg}
Do I am doing right ? Is there any way I can see in cqlsh to conform storing order ?
Thanks.
The easiest way to validate that the underlying storage rows look as desired is to test using the CLI. So if I do the following in CQL:
cqlsh:test> CREATE TABLE Message (category_id varchar, msg_id varchar, msg varchar, PRIMARY KEY (category_id, msg_id));
cqlsh:test> INSERT INTO Message (category_id, msg_id, msg) VALUES ('catid1', 'msgid1', 'This is a test');
cqlsh:test> SELECT * FROM Message;
category_id | msg_id | msg
-------------+--------+----------------
catid1 | msgid1 | This is a test
(1 rows)
... then I run the CLI (cassandra-cli
) as follows:
[default@test] assume Message validator as ascii;
Assumption for column family 'message' added successfully.
[default@test] list Message;
Using default limit of 100
Using default cell limit of 100
-------------------
RowKey: catid1
=> (name=msgid1:, value=, timestamp=1380832937863000)
=> (name=msgid1:msg, value=This is a test, timestamp=1380832937863000)
You can see clearly that the rows look as desired. You can ignore the empty column at the top, as this is used internally by Cassandra.