SlideShare a Scribd company logo
CS331 - Database Management Systems


Dr. Lilia Sfaxi


6 novembre 2019


Cassandra


To get a docker container with cassandra:


docker pull cassandra


docker run --name medtech-cassandra -d cassandra:latest


docker exec -it medtech-cassandra cqlsh


create a keyspace:


CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy',
'replication_factor' : 1};


see all keyspaces:


describe keyspaces;


use the keyspace:


use mykeyspace ;


create table:


create table users( user_id int primary key, fname text, lname text);


show all tables in the keyspace:


describe tables;


insert values:


INSERT INTO users (user_id, fname, lname) VALUES (1745, 'john', 'smith');


see inserted values:


select * from users;


CASSANDRA DR. LILIA SFAXI 1
MedTech
read requests (see the results)


select * from users where user_id < 2000;


select * from users where user_id = 1745;


select * from users where lname = 'smith';


indexing columns:


CREATE INDEX ON users (lname);


SELECT * FROM users WHERE lname = 'smith';


Create a table with composite key :


CREATE TABLE tab2 (


id1 int,


id2 int,


fi
rst_name varchar,


last_name varchar,


PRIMARY KEY (id1, id2));


Add a new column to the table:


ALTER TABLE users ADD telephone text;


Alter the value of a row:


UPDATE users SET telephone = '21212121' where user_id = 1745;


Empty a table:


TRUNCATE users;


Delete a table:


DROP table users;


Create a table with sets:


CREATE TABLE users (user_id int PRIMARY KEY, fname text, lname text,emails set<text>);


Insert values in a set:


CASSANDRA DR. LILIA SFAXI 2
INSERT INTO users (user_id, fname, lname, emails)VALUES(1234, 'Frodo', 'Baggins',
{'f@baggins.com', 'baggins@gmail.com'});


Add an element to a set:


UPDATE users SET emails = emails + {'fb@friendsofmordor.org'} WHERE user_id = 1234;


Extract email addresses:


SELECT user_id, emails FROM users WHERE user_id = 1234;


Delete an element from the set:


UPDATE users SET emails = emails - {'fb@friendsofmordor.org'} WHERE user_id = 1234;


To delete all elements:


UPDATE users SET emails = {} WHERE user_id = 1234;


or


DELETE emails FROM users WHERE user_id = 1234;


create a list:


ALTER TABLE users ADD top_places list<text>;


insert elements in the list:


UPDATE users SET top_places = [ 'rivendell', 'rohan' ] WHERE user_id = 1234;


to add a new element in the list:


UPDATE users SET top_places = top_places + [ 'mordor' ] WHERE user_id = 1234;


to insert an element at a given position (old value will be replaced):


UPDATE users SET top_places[1] = 'riddermark' WHERE user_id = 1234;


delete an element from the list, using its index:


DELETE top_places[2] FROM users WHERE user_id = 1234;


delete all elements with a given value:


UPDATE users SET top_places = top_places - ['riddermark'] WHERE user_id = 1234;


CASSANDRA DR. LILIA SFAXI 3
create a map:


ALTER TABLE users ADD todo map<timestamp, text> ;


insert an element in the map:


UPDATE users SET todo = { '2012-9-24' : 'enter mordor', '2012-10-2 12:00' : 'throw ring into
mount doom', toTimestamp(now()): 'die!'} WHERE user_id = 1234;


insert a speci
fi
c element by id:


UPDATE users SET todo['2012-10-2 12:00'] = 'throw my precious into mount doom' WHERE
user_id = 1234;


replace the whole map with insert:


INSERT INTO users (user_id,todo) VALUES ( 1234, { '2013-9-22 12:01' : 'birthday wishes to
Bilbo', '2013-10-1 18:00' : 'Check into Inn of Prancing Pony' });


delete an element in the map:


DELETE todo['2012-9-24'] FROM users WHERE user_id = 1234;




Activity


- Design the enrollment example for a column-based database like cassandra


- Create the tables and run some queries to test
CASSANDRA DR. LILIA SFAXI 4

More Related Content

What's hot

Cours Big Data Chap3
Cours Big Data Chap3Cours Big Data Chap3
Cours Big Data Chap3
Amal Abid
 
Spark RDD : Transformations & Actions
Spark RDD : Transformations & ActionsSpark RDD : Transformations & Actions
Spark RDD : Transformations & Actions
MICHRAFY MUSTAFA
 
Chapitre 2 hadoop
Chapitre 2 hadoopChapitre 2 hadoop
Chapitre 2 hadoop
Mouna Torjmen
 
BigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-ReduceBigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-Reduce
Lilia Sfaxi
 
Apache sqoop with an use case
Apache sqoop with an use caseApache sqoop with an use case
Apache sqoop with an use case
Davin Abraham
 
Projet security et datawarehouse
Projet security et datawarehouseProjet security et datawarehouse
Projet security et datawarehouse
omri med
 
Big Data, Hadoop & Spark
Big Data, Hadoop & SparkBig Data, Hadoop & Spark
Big Data, Hadoop & Spark
Alexia Audevart
 
Data models in NoSQL
Data models in NoSQLData models in NoSQL
Data models in NoSQL
Dr-Dipali Meher
 
Intégration des données avec Talend ETL
Intégration des données avec Talend ETLIntégration des données avec Talend ETL
Intégration des données avec Talend ETL
Lilia Sfaxi
 
Introduction à Neo4j
Introduction à Neo4jIntroduction à Neo4j
Introduction à Neo4j
Neo4j
 
Introduction aux bases de données NoSQL
Introduction aux bases de données NoSQLIntroduction aux bases de données NoSQL
Introduction aux bases de données NoSQL
Antoine Augusti
 
Base de donnees Avancees et Intro à NoSQL.ppt
Base de donnees Avancees et Intro à  NoSQL.pptBase de donnees Avancees et Intro à  NoSQL.ppt
Base de donnees Avancees et Intro à NoSQL.ppt
Idriss22
 
BigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-ReduceBigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-Reduce
Lilia Sfaxi
 
Cours Big Data Chap2
Cours Big Data Chap2Cours Big Data Chap2
Cours Big Data Chap2
Amal Abid
 
DataWarehouse
DataWarehouseDataWarehouse
DataWarehouse
nzuguem
 
Python For Data Science - French Course
Python For Data Science - French CoursePython For Data Science - French Course
Python For Data Science - French Course
Haytam EL YOUSSFI
 
alphorm.com - Formation Linux LPIC-1/Comptia Linux+
alphorm.com - Formation Linux LPIC-1/Comptia Linux+alphorm.com - Formation Linux LPIC-1/Comptia Linux+
alphorm.com - Formation Linux LPIC-1/Comptia Linux+
Alphorm
 
Big Data with MySQL
Big Data with MySQLBig Data with MySQL
Big Data with MySQL
Ivan Zoratti
 
Presentation cassandra
Presentation cassandraPresentation cassandra
Presentation cassandra
fatima zahra FANDI
 

What's hot (20)

Cours Big Data Chap3
Cours Big Data Chap3Cours Big Data Chap3
Cours Big Data Chap3
 
Spark RDD : Transformations & Actions
Spark RDD : Transformations & ActionsSpark RDD : Transformations & Actions
Spark RDD : Transformations & Actions
 
Chapitre 2 hadoop
Chapitre 2 hadoopChapitre 2 hadoop
Chapitre 2 hadoop
 
BigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-ReduceBigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-Reduce
 
Apache sqoop with an use case
Apache sqoop with an use caseApache sqoop with an use case
Apache sqoop with an use case
 
Projet security et datawarehouse
Projet security et datawarehouseProjet security et datawarehouse
Projet security et datawarehouse
 
Big Data, Hadoop & Spark
Big Data, Hadoop & SparkBig Data, Hadoop & Spark
Big Data, Hadoop & Spark
 
Data models in NoSQL
Data models in NoSQLData models in NoSQL
Data models in NoSQL
 
Data warehouse
Data warehouseData warehouse
Data warehouse
 
Intégration des données avec Talend ETL
Intégration des données avec Talend ETLIntégration des données avec Talend ETL
Intégration des données avec Talend ETL
 
Introduction à Neo4j
Introduction à Neo4jIntroduction à Neo4j
Introduction à Neo4j
 
Introduction aux bases de données NoSQL
Introduction aux bases de données NoSQLIntroduction aux bases de données NoSQL
Introduction aux bases de données NoSQL
 
Base de donnees Avancees et Intro à NoSQL.ppt
Base de donnees Avancees et Intro à  NoSQL.pptBase de donnees Avancees et Intro à  NoSQL.ppt
Base de donnees Avancees et Intro à NoSQL.ppt
 
BigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-ReduceBigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-Reduce
 
Cours Big Data Chap2
Cours Big Data Chap2Cours Big Data Chap2
Cours Big Data Chap2
 
DataWarehouse
DataWarehouseDataWarehouse
DataWarehouse
 
Python For Data Science - French Course
Python For Data Science - French CoursePython For Data Science - French Course
Python For Data Science - French Course
 
alphorm.com - Formation Linux LPIC-1/Comptia Linux+
alphorm.com - Formation Linux LPIC-1/Comptia Linux+alphorm.com - Formation Linux LPIC-1/Comptia Linux+
alphorm.com - Formation Linux LPIC-1/Comptia Linux+
 
Big Data with MySQL
Big Data with MySQLBig Data with MySQL
Big Data with MySQL
 
Presentation cassandra
Presentation cassandraPresentation cassandra
Presentation cassandra
 

Similar to Lab1-DB-Cassandra

CQL - Cassandra commands Notes
CQL - Cassandra commands NotesCQL - Cassandra commands Notes
CQL - Cassandra commands Notes
Sunil Kumar Gunasekaran
 
Apache Cassandra Lesson: Data Modelling and CQL3
Apache Cassandra Lesson: Data Modelling and CQL3Apache Cassandra Lesson: Data Modelling and CQL3
Apache Cassandra Lesson: Data Modelling and CQL3
Markus Klems
 
Getting Started with PL/Proxy
Getting Started with PL/ProxyGetting Started with PL/Proxy
Getting Started with PL/Proxy
Peter Eisentraut
 
How te bring common UI patterns to ADF
How te bring common UI patterns to ADFHow te bring common UI patterns to ADF
How te bring common UI patterns to ADF
Getting value from IoT, Integration and Data Analytics
 
Modify this code to change the underlying data structure to .pdf
Modify this code to change the underlying data structure to .pdfModify this code to change the underlying data structure to .pdf
Modify this code to change the underlying data structure to .pdf
adityaenterprise32
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
feroz544
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
FilestreamFilestream
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF
Luc Bors
 
Windows power shell and active directory
Windows power shell and active directoryWindows power shell and active directory
Windows power shell and active directory
Dan Morrill
 
Les10
Les10Les10
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
Bruno Rocha
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
Gokhan Atil
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
HostedbyConfluent
 
SQL WORKSHOP::Lecture 10
SQL WORKSHOP::Lecture 10SQL WORKSHOP::Lecture 10
SQL WORKSHOP::Lecture 10
Umair Amjad
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Oracle
OracleOracle
Oracle
Yo Seven
 
Mysql
MysqlMysql
Mysql
ksujitha
 
Sah
SahSah
Sql
SqlSql
Operator overload rr
Operator overload  rrOperator overload  rr
Operator overload rr
Dhivya Shanmugam
 

Similar to Lab1-DB-Cassandra (20)

CQL - Cassandra commands Notes
CQL - Cassandra commands NotesCQL - Cassandra commands Notes
CQL - Cassandra commands Notes
 
Apache Cassandra Lesson: Data Modelling and CQL3
Apache Cassandra Lesson: Data Modelling and CQL3Apache Cassandra Lesson: Data Modelling and CQL3
Apache Cassandra Lesson: Data Modelling and CQL3
 
Getting Started with PL/Proxy
Getting Started with PL/ProxyGetting Started with PL/Proxy
Getting Started with PL/Proxy
 
How te bring common UI patterns to ADF
How te bring common UI patterns to ADFHow te bring common UI patterns to ADF
How te bring common UI patterns to ADF
 
Modify this code to change the underlying data structure to .pdf
Modify this code to change the underlying data structure to .pdfModify this code to change the underlying data structure to .pdf
Modify this code to change the underlying data structure to .pdf
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF
 
Windows power shell and active directory
Windows power shell and active directoryWindows power shell and active directory
Windows power shell and active directory
 
Les10
Les10Les10
Les10
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
 
SQL WORKSHOP::Lecture 10
SQL WORKSHOP::Lecture 10SQL WORKSHOP::Lecture 10
SQL WORKSHOP::Lecture 10
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
 
Oracle
OracleOracle
Oracle
 
Mysql
MysqlMysql
Mysql
 
Sah
SahSah
Sah
 
Sql
SqlSql
Sql
 
Operator overload rr
Operator overload  rrOperator overload  rr
Operator overload rr
 

More from Lilia Sfaxi

chp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdfchp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdf
Lilia Sfaxi
 
Plan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdfPlan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdf
Lilia Sfaxi
 
Lab3-DB_Neo4j
Lab3-DB_Neo4jLab3-DB_Neo4j
Lab3-DB_Neo4j
Lilia Sfaxi
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-Correction
Lilia Sfaxi
 
TP1-UML-Correction
TP1-UML-CorrectionTP1-UML-Correction
TP1-UML-Correction
Lilia Sfaxi
 
TP0-UML-Correction
TP0-UML-CorrectionTP0-UML-Correction
TP0-UML-Correction
Lilia Sfaxi
 
TD4-UML
TD4-UMLTD4-UML
TD4-UML
Lilia Sfaxi
 
TD4-UML-Correction
TD4-UML-CorrectionTD4-UML-Correction
TD4-UML-Correction
Lilia Sfaxi
 
TD3-UML-Séquences
TD3-UML-SéquencesTD3-UML-Séquences
TD3-UML-Séquences
Lilia Sfaxi
 
TD3-UML-Correction
TD3-UML-CorrectionTD3-UML-Correction
TD3-UML-Correction
Lilia Sfaxi
 
TD2 - UML - Correction
TD2 - UML - CorrectionTD2 - UML - Correction
TD2 - UML - Correction
Lilia Sfaxi
 
TD1 - UML - DCU
TD1 - UML - DCUTD1 - UML - DCU
TD1 - UML - DCU
Lilia Sfaxi
 
TD1-UML-correction
TD1-UML-correctionTD1-UML-correction
TD1-UML-correction
Lilia Sfaxi
 
Android - Tp1 - installation et démarrage
Android - Tp1 -   installation et démarrageAndroid - Tp1 -   installation et démarrage
Android - Tp1 - installation et démarrage
Lilia Sfaxi
 
Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques
Lilia Sfaxi
 
Android - Tp3 - intents
Android - Tp3 -  intentsAndroid - Tp3 -  intents
Android - Tp3 - intents
Lilia Sfaxi
 
Android - TPBonus - web services
Android - TPBonus - web servicesAndroid - TPBonus - web services
Android - TPBonus - web services
Lilia Sfaxi
 
Android - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancésAndroid - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancés
Lilia Sfaxi
 
Android - Tp 5 - stockage de données
Android - Tp 5 -  stockage de donnéesAndroid - Tp 5 -  stockage de données
Android - Tp 5 - stockage de données
Lilia Sfaxi
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
Lilia Sfaxi
 

More from Lilia Sfaxi (20)

chp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdfchp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdf
 
Plan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdfPlan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdf
 
Lab3-DB_Neo4j
Lab3-DB_Neo4jLab3-DB_Neo4j
Lab3-DB_Neo4j
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-Correction
 
TP1-UML-Correction
TP1-UML-CorrectionTP1-UML-Correction
TP1-UML-Correction
 
TP0-UML-Correction
TP0-UML-CorrectionTP0-UML-Correction
TP0-UML-Correction
 
TD4-UML
TD4-UMLTD4-UML
TD4-UML
 
TD4-UML-Correction
TD4-UML-CorrectionTD4-UML-Correction
TD4-UML-Correction
 
TD3-UML-Séquences
TD3-UML-SéquencesTD3-UML-Séquences
TD3-UML-Séquences
 
TD3-UML-Correction
TD3-UML-CorrectionTD3-UML-Correction
TD3-UML-Correction
 
TD2 - UML - Correction
TD2 - UML - CorrectionTD2 - UML - Correction
TD2 - UML - Correction
 
TD1 - UML - DCU
TD1 - UML - DCUTD1 - UML - DCU
TD1 - UML - DCU
 
TD1-UML-correction
TD1-UML-correctionTD1-UML-correction
TD1-UML-correction
 
Android - Tp1 - installation et démarrage
Android - Tp1 -   installation et démarrageAndroid - Tp1 -   installation et démarrage
Android - Tp1 - installation et démarrage
 
Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques
 
Android - Tp3 - intents
Android - Tp3 -  intentsAndroid - Tp3 -  intents
Android - Tp3 - intents
 
Android - TPBonus - web services
Android - TPBonus - web servicesAndroid - TPBonus - web services
Android - TPBonus - web services
 
Android - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancésAndroid - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancés
 
Android - Tp 5 - stockage de données
Android - Tp 5 -  stockage de donnéesAndroid - Tp 5 -  stockage de données
Android - Tp 5 - stockage de données
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
 

Recently uploaded

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 

Recently uploaded (20)

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 

Lab1-DB-Cassandra

  • 1. CS331 - Database Management Systems Dr. Lilia Sfaxi 6 novembre 2019 Cassandra To get a docker container with cassandra: docker pull cassandra docker run --name medtech-cassandra -d cassandra:latest docker exec -it medtech-cassandra cqlsh create a keyspace: CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1}; see all keyspaces: describe keyspaces; use the keyspace: use mykeyspace ; create table: create table users( user_id int primary key, fname text, lname text); show all tables in the keyspace: describe tables; insert values: INSERT INTO users (user_id, fname, lname) VALUES (1745, 'john', 'smith'); see inserted values: select * from users; CASSANDRA DR. LILIA SFAXI 1 MedTech
  • 2. read requests (see the results) select * from users where user_id < 2000; select * from users where user_id = 1745; select * from users where lname = 'smith'; indexing columns: CREATE INDEX ON users (lname); SELECT * FROM users WHERE lname = 'smith'; Create a table with composite key : CREATE TABLE tab2 ( id1 int, id2 int, fi rst_name varchar, last_name varchar, PRIMARY KEY (id1, id2)); Add a new column to the table: ALTER TABLE users ADD telephone text; Alter the value of a row: UPDATE users SET telephone = '21212121' where user_id = 1745; Empty a table: TRUNCATE users; Delete a table: DROP table users; Create a table with sets: CREATE TABLE users (user_id int PRIMARY KEY, fname text, lname text,emails set<text>); Insert values in a set: CASSANDRA DR. LILIA SFAXI 2
  • 3. INSERT INTO users (user_id, fname, lname, emails)VALUES(1234, 'Frodo', 'Baggins', {'f@baggins.com', 'baggins@gmail.com'}); Add an element to a set: UPDATE users SET emails = emails + {'fb@friendsofmordor.org'} WHERE user_id = 1234; Extract email addresses: SELECT user_id, emails FROM users WHERE user_id = 1234; Delete an element from the set: UPDATE users SET emails = emails - {'fb@friendsofmordor.org'} WHERE user_id = 1234; To delete all elements: UPDATE users SET emails = {} WHERE user_id = 1234; or DELETE emails FROM users WHERE user_id = 1234; create a list: ALTER TABLE users ADD top_places list<text>; insert elements in the list: UPDATE users SET top_places = [ 'rivendell', 'rohan' ] WHERE user_id = 1234; to add a new element in the list: UPDATE users SET top_places = top_places + [ 'mordor' ] WHERE user_id = 1234; to insert an element at a given position (old value will be replaced): UPDATE users SET top_places[1] = 'riddermark' WHERE user_id = 1234; delete an element from the list, using its index: DELETE top_places[2] FROM users WHERE user_id = 1234; delete all elements with a given value: UPDATE users SET top_places = top_places - ['riddermark'] WHERE user_id = 1234; CASSANDRA DR. LILIA SFAXI 3
  • 4. create a map: ALTER TABLE users ADD todo map<timestamp, text> ; insert an element in the map: UPDATE users SET todo = { '2012-9-24' : 'enter mordor', '2012-10-2 12:00' : 'throw ring into mount doom', toTimestamp(now()): 'die!'} WHERE user_id = 1234; insert a speci fi c element by id: UPDATE users SET todo['2012-10-2 12:00'] = 'throw my precious into mount doom' WHERE user_id = 1234; replace the whole map with insert: INSERT INTO users (user_id,todo) VALUES ( 1234, { '2013-9-22 12:01' : 'birthday wishes to Bilbo', '2013-10-1 18:00' : 'Check into Inn of Prancing Pony' }); delete an element in the map: DELETE todo['2012-9-24'] FROM users WHERE user_id = 1234; Activity - Design the enrollment example for a column-based database like cassandra - Create the tables and run some queries to test CASSANDRA DR. LILIA SFAXI 4