Cassandra Query Language (CQL)

Introduction

  • Cassandra system allows the users to access data by using its nodes with the help of CQL.
  • A programmer can use a cqlsh: A utility to work with CQL, or programmer can work with separate application language drivers.
  • A client can use any node to perform read or write operation. These nodes are known as coordinators and act as proxy between the client and the nodes containing the data.

Write operations

  • Commit log is written for every write operation and the data for this is stored in mem-table.
  • When the mem-table gets full, the data for storage can be written into the SSTable data file.
  • After this, Write operations can be automatically partitioned and replicated through the cluster.
  • Cassandra system consolidates the SSTable periodically and discards the unwanted data.

Read Operations

A mem-table provides the values to Cassandra system to perform the read operations.

Components of CQL data model

The basic components of CQL data are stated as:

1. Cluster
Cassandra database can be distributed by using one or more nodes. The collection of these nodes acts as a cluster. Cassandra helps to arrange all the nodes in a ring formation and thereby assigns data to them.

2. Keyspace
A keyspace in Cassandra defines the data replication on nodes and acts like a container for data in Cassandra.

3. Replication factor
Replication factor in Cassandra can be stated as the number of nodes in cluster containing the same data. Replication strategy assists in placing the replicas in the ring format.