This repository provides a docker-compose needed to start a 3 node cassandra cluster
$ git clone https://github.com/eSolutionsGrup/cassandra-intro.git
$ cd cassandra-intro
$ docker-compose up -d
$ docker exec -ti {container_name} cqlsh
CREATE KEYSPACE bdwvideo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
use bdwvideo;
CREATE TABLE user_credentials(
email text,
password text,
userid uuid,
primary key (email)
);
CREATE TABLE users(
userid uuid,
firstname text,
lastname text,
email text,
created_date timestamp,
primary key (userid)
);
INSERT INTO users (userid , firstname , lastname , email , created_date) VALUES ( uuid(),'john','doe','john@doe', '2021-10-09');
SELECT uuid from users;
UPDATE users set lastname='Johnson' where userid = ;
SELECT userid from users;
UPDATE users set lastname='Johnson' where userid = a62485ed-f11d-485e-bd24-14b25a5ba0ff;
);
CREATE TABLE videos(
videoid uuid,
userid uuid,
name text,
description text,
location text,
location_type int,
preview_image_location text,
tags set<text>,
added_date timestamp,
primary key (videoid)
);
CREATE TABLE user_videos(
userid uuid,
added_date timestamp,
videoid uuid,
name text,
preview_image_location text,
primary key (userid, added_date, videoid)
) with clustering order by (
added_date desc,
videoid asc);
CREATE TABLE latest_videos(
video_date text,
added_date timestamp,
videoid uuid,
name text,
preview_image_location text,
primary key (video_date, added_date, videoid))
with clustering order by (added_date desc, videoid asc);
insert into latest_videos ( video_date , added_date , videoid , name , preview_image_location ) VALUES ( '2021-10-12', toTimestamp(now()), uuid(),'best name','best preview');
insert into latest_videos ( video_date , added_date , videoid , name , preview_image_location ) VALUES ( '2021-10-12', toTimestamp(now()), uuid(),'best name','best preview');
insert into latest_videos ( video_date , added_date , videoid , name , preview_image_location ) VALUES ( '2021-10-12', toTimestamp(now()), uuid(),'best name','best preview');
CREATE TABLE latest_videos_bucketed(
video_date text,
bucket int,
added_date timestamp,
videoid uuid,
name text,
preview_image_location text,
primary key ((video_date, bucket), added_date, videoid))
with clustering order by (added_date desc, videoid asc);
insert into latest_videos_bucketed ( video_date ,bucket, added_date , videoid , name , preview_image_location ) VALUES ( '2021-10-12',0, toTimestamp(now()), uuid(),'best name','best preview');
insert into latest_videos_bucketed ( video_date ,bucket, added_date , videoid , name , preview_image_location ) VALUES ( '2021-10-12',1, toTimestamp(now()), uuid(),'best name','best preview');
select * from latest_videos_bucketed where video_date = '2021-10-12' and bucket in (0,1);
select * from latest_videos_bucketed where video_date = '2021-10-12' and bucket = 0;
select * from latest_videos_bucketed where video_date = '2021-10-12' and bucket = 1;
https://cassandra.apache.org/doc/latest/cassandra/tools/cassandra_stress.html