In Azure Cosmos DB, Cassandra API can be used as the data store for the applications that have been written for Apache Cassandra.
This means that the applications users have built using Apache Cassandra can communicate with Cosmos DB using the Cassandra API. And this can be achieved simply by changing the connection string.
This API helps us to interact with the data stored in Azure Cosmos DB using the Cassandra Query Language (CQL), Cassandra-based tools, and Cassandra client drivers.
Some of the benefits of using the Cassandra API for Cosmos DB are:
- Cassandra can handle high read/write throughputs
- Guarantees the consistency of throughputs
- Handles workload when working with messaging apps, fraud detection, etc.
- There is no single point of failure
- Cosmos DB scales a Cassandra cluster to add more nodes without requiring any manual configuration.
- Friendly to work with CQL if a prior experience with SQL
Let us take a look at basic CRUD functionality using CQL (Cassandra Query Language)
Create Operation
INSERT INTO KeyspaceName.TableName (ColName1, ColName2, ColName3 . . . )
VALUES (Col1Value, Col2Value, Col3Value . . . )
Read Operation
SELECT ColName1, ColName2, ColName3 . . .
FROM KeyspaceName.TableName
WHERE ColName1 = Col1Value AND
ColName2 = Col2Value AND
ColName2 = Col2Value AND
. . .
Update Operation
UPDATE KeyspaceName.TableName
SET ColName1 = new Col1Value,
ColName2 = new Col2Value,
ColName3 = new Col3Value,
. . .
WHERE ColName1 = ColValue
Delete Operation
DELETE FROM KeyspaceName.TableName
WHERE ColName1 = ColValue
Summary
In this blog post, we learned about the Cassandra API usage in Cosmos DB. We saw it acts as a data store for the data stored in Azure. We also saw the benefits of using Cassandra API in Cosmos DB.
We learned how to perform CRUD operations using CQL in Cassandra API for Cosmos DB.
Leave a Reply