Flat 10% & up to 50% off + Free additional Courses. Hurry up!

Brief Introduction to Cassandra Query Language (CQL)


CQL is simple api mean for accessing Cassandra.CQL adds an abstraction layer that hides implementation details of this structure and provides native syntaxes for collections and other common encodings.


Common ways to access CQL are:

• Start cqlsh, the Python-based command-line client, on the command line of a Cassandra node.

• For developing applications, use one of the C#, Java, or Python open-source drivers.

• Use the set_cql_version Thrift method for programmatic access

Below are common operation we can do with CQL


1.) Creating and using key space:

cqlsh> CREATE KEYSPACE demodb WITH REPLICATION = { ‘class’ :

‘NetworkTopologyStrategy’, ‘datacenter1′ : 3 };

USE demodb;


2.) Alter Key Space

ALTER KEYSPACE ” demodb ” WITH REPLICATION = { ‘class’ : ‘SimpleStrategy’,

‘replication_factor’ : 2};


3.) Create Table

CREATE TABLE emp ( empID int, deptID int, first_name varchar,last_name varchar, PRIMARY KEY (empID, deptID));


4.) Insert into table

INSERT INTO emp (empID, deptID, first_name, last_name) VALUES (104, 15, ‘jane’, ‘smith’);


5.) Select query Select * from emp;

Scaling online library with Cassandra

Let’s talk about a very simple example of online books library. In relation database the system will have multiple normalized schemas. Few of very important one are described below:


img 6


As with introduction of “free users” and “unlimited books at my dispose” features in online book library, popularity of app increased to great extend .Resultant was flood of customer data. These made RDBMS setup unstable and business decided to go with Cassandra to mitigate the issue.

Before designing Cassandra table we need to find out all possible queries which key space shall support.

Most fired queries would be:

1.) Get books of category with availability >0

2.) Get books from same author Queries for business point of view

3.) Get Customer liking per geographic location

4.) Most liked category

So in order to incorporate this quicker we need to de-normalize data and create new column families.


img 7

A detailed understanding of Apache Cassandra is available in this blog post for your perusal!

"0 Responses on Brief Introduction to Cassandra Query Language (CQL)"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.


Sales Offer

  • To avail this offer, enroll before 23rd October 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer


Sign Up or Login to view the Free Brief Introduction to Cassandra Query Language (CQL).