1. For quick introduction of Cassandra Data Model : Cassandra Data Model of Max Version
  2. CLI API Exercise :Note 1 – For every command or statement you enter into the CLI, make sure you enter a semicolon at the end before hitting the return key. If you forget to do this, the CLI echos an ellipsis ( . . . ), which indicates that the CLI expects more input – such as a semicolon, or names and values in other cases.

Connect to “Test Cluster”

$ ./cassandra-cli -host localhost -port 9160

Create KeySpace

[default@unknown] create keyspace twissandra with replication_factor=1and placement_strategy=’org.apache.cassandra.locator.SimpleStrategy’;
More reference of KeySpace, you could find in the following link – Cluster about Key Spacing

Creating a Column Family

[default@unknown] use twissandra;
Authenticated to keyspace: twissandra
[default@twissandra] create column family users with comparator = UTF8Type
…     and column_metadata = [{column_name: password, validation_class:
…     UTF8Type}];
[cc792bbc-5ecb-11e0-9ff3-f038a2a19b21] <= output schema of password

Similar commands to create the columns families for Twissandra tweets, followers, userline and timeline would look like the following:

[default@twissandra] create column family tweets with comparator = UTF8Type and column_metadata = [{column_name: body, validation_class:UTF8Type}, {column_name: username, validation_class: UTF8Type}];
[5385025d-5ecc-11e0-9ff3-f038a2a19b21] <= output schema of tweets

[default@twissandra] create column family friends with comparator = UTF8Type;
[61c0f5ee-5ecc-11e0-9ff3-f038a2a19b21]<= output schema of friends

[default@twissandra] create column family followers with comparator = UTF8Type;
[6d62ddaf-5ecc-11e0-9ff3-f038a2a19b21]<= output schema of followers

[default@twissandra] create column family userline with comparator = LongType and default_validation_class = TimeUUIDType;
[78bac420-5ecc-11e0-9ff3-f038a2a19b21]<=output schema of userline

[default@twissandra] create column family timeline with comparator = LongType and default_validation_class = TimeUUIDType;
[8504d2c1-5ecc-11e0-9ff3-f038a2a19b21]<=output schema of timeline

Inserting and Retrieving Columns

[default@twissandra] set users[‘jsmith’][‘password’]=’ch@ngem3′;
Value inserted.
[default@twissandra] get users[‘jsmith’];
=> (column=password, value=ch@ngem3, timestamp=1301929424925000)
Returned 1 results.

Note 2 – For all CLI write and read operations such as these example commands, the consistency level is ONE. Different consistency levels are not available with the CLI, though all levels are available when writing/reading programatically.