MLearning.ai
Published in

MLearning.ai

An Introduction to Cassandra

Image 1

CAP Theorem

Select Count(Distinct userid)
from users
Image 2
  1. Keyspace:- Keyspace is similar to a data container in the Cassandra database which is similar to a schema in the database. Keyspace consists of core objects e.g:- column families, rows indexed by keys(primary key), data types, data center, and replications factors.

2. Keys in Cassandra

Image: Cassandra Cluster
/* Simple example to assign partition key */
create table application_log( id int,
user_name varchar,
user_age as int,
user_login as timstamp
user_ordered as varchar
Primary Key(user_name)
);
/* Simple example to assign composite partition key */
create table application_log( id int,
user_name varchar,
user_age as int,
user_login as timstamp
user_ordered as varchar
Primary Key(user_name,user_age)
);
/* Simple example to assign composite partition key */
create table application_log( id int,
user_name varchar,
user_age as int,
user_login as timstamp
user_ordered as varchar
Primary Key((user_name,user_age),user_ordered)
)
with clustering order by (user_ordered desc);

3. Data Replication in Cassandra

Image 3
Image: Simple Replication Strategy
Image: Network topology Replication Strategy

--

--

Data Scientists must think like an artist when finding a solution when creating a piece of code. ⚪️ Artists enjoy working on interesting problems, even if there is no obvious answer ⚪️ linktr.ee/mlearning 🔵 Follow to join our 28K+ Unique DAILY Readers 🟠

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store