DEV Community

Cover image for Break Down of Apache Cassandra Databaseđź’ľ
Farhad Rahimi Klie
Farhad Rahimi Klie

Posted on

Break Down of Apache Cassandra Databaseđź’ľ

What is Apache Cassandra ?

apache Cassandra is a distributed and No-SQL database management system and use for big Data and Analytics on big Companies.
Store data in table form like relational databases but differently.

Main Part of Cassandra DB

1 - KeySpace
2 - Table
3 - Row/Columns
4 - Primary Key (Partition Key, Clustering Key)

Key Features of Cassandra

1 - Distributed:
Data is stored across multiple servers (nodes). If one server fails, data isn’t lost.
2 - Horizontal Scalability:
You can add new nodes anytime without shutting down the system.
3 - Fault Tolerance:
Data is automatically replicated across nodes. If one or more servers fail, the system keeps running.
4 - High Performance:
Cassandra can handle millions of requests per second with low latency.
5 - No Single Point of Failure:
Unlike traditional databases, there is no central master node.
6 - Schema-Free / Flexible:
Similar to MongoDB, Cassandra allows flexible data modeling without a fixed schema.

🔄 Cassandra Architecture

Cassandra uses a Peer-to-Peer architecture:

1 - All nodes are equal (unlike Master-Slave in traditional DBs).

2 - Data is distributed across nodes using Consistent Hashing.

3 - Nodes communicate using the Gossip Protocol.

Main Components:

1 - Cluster: A group of nodes.

2 - Node: A single server that stores data.

3 - Keyspace: Similar to a database in SQL.

4 - Table: Data tables (similar to SQL but more flexible).

5 - Row & Column: Data is stored in rows and columns.

6 - Partition Key: The key that determines how data is distributed across nodes.

Data Model in Cassandra

Cassandra combines Key-Value Store and Column-Oriented Database.

1 - Data is grouped by a key (partition key).

2 - Each key contains multiple columns.

3 - Columns can be dynamic (no need to predefine all).

Cassandra Query Language (CQL)

Cassandra has its own query language called CQL, which looks very similar to SQL.

-- Create a Keyspace
CREATE KEYSPACE my_app 
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3};

-- Use Keyspace
USE my_app;

-- Create a Table
CREATE TABLE users (
   id UUID PRIMARY KEY,
   name TEXT,
   email TEXT,
   age INT
);

-- Insert Data
INSERT INTO users (id, name, email, age)
VALUES (uuid(), 'Farhad', 'farhad@example.com', 25);

-- Select Data
SELECT * FROM users;

-- Update Data
UPDATE users SET age = 26 WHERE id = some-uuid;

-- Delete Data
DELETE FROM users WHERE id = some-uuid;

Enter fullscreen mode Exit fullscreen mode

📌 When to Use Cassandra

Cassandra is ideal when:

1 - You have huge volumes of data.

2 - You need high scalability.

3 - You require real-time access.

4 - Your system must be always available (Always On).

âś… Pros

1 - Unlimited scalability.

2 - Very high performance in reads/writes.

3 - Fault-tolerance with replication.

4 - No single point of failure.

❌ Cons

1 - Harder to learn compared to SQL.

2 - Weaker in complex queries vs. relational DBs.

3 - Requires expertise for tuning and management.

👉 Summary:

Cassandra is a NoSQL, distributed, and highly scalable database designed for applications that must handle huge data volumes and be always online.

Top comments (0)