SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
Data modeling with 
Apache Cassandra 
Marko Švaljek 
@msvaljek
About me 
• Software Developer at Kapsch 
• Zagreb Cassandra Meetup
About Cassandra 
• Written in Java 
• Wide Row Store 
• Masterless 
• DataStax
About Cassandra 
• No Single Point of failure ✓ 
• Cross Datacenter ✓ 
• Linear Scaling ✓ 
• Data modeling ?
Data Model 
• Highly denormalized 
• No foreign keys 
• No referential integrity 
• No joins
Compared to Relational 
• Think about the questions up front 
• No penalty for wide rows 
• Disk is cheap 
• Bring on the writes
Cassandra Objects 
• Keyspace (database) 
• Table 
• Primary key 
• Index
Data Organization
Wide Row
CQL 
• Cassandra Query Language 
• Similar to SQL 
• Learning curve 
• No code reading
Create table 
CREATE TABLE employees ( 
name text PRIMARY KEY, 
age int, 
role text 
);
Inserting 
INSERT INTO employees 
(name, age) 
VALUES ('mario', 38); 
INSERT INTO employees 
(name, age) 
VALUES ('tom', 24);
Selecting 
SELECT * FROM employees; 
name | age | role 
-------+-----+------ 
tom | 24 | DEV 
mario | 38 | SM
Hmm … 
SELECT * 
FROM employees 
WHERE age > 20; 
Bad Request: No indexed 
columns present in by-columns 
clause with Equal operator
How it’s stored 
• Every row is a partition 
• There is no “next” row
Primary key 
CREATE TABLE employees2 ( 
company text, 
name text, 
age int, 
role text, 
PRIMARY KEY (company, name) 
);
Primary key 
company | name | age | role 
---------+-------+-----+------ 
B | john | 25 | DEV 
B | peter | 22 | DEV 
A | kate | 33 | PM 
A | mario | 38 | SM 
A | neno | 32 | DEV 
PRIMARY KEY (company, name)
Primary key 
company | name | age | role 
---------+-------+-----+------ 
B | john | 25 | DEV 
B | peter | 22 | DEV 
A | kate | 33 | PM 
A | mario | 38 | SM 
A | neno | 32 | DEV
Primary key 
SELECT * 
FROM employees2 
WHERE company = 'A' 
AND name > 'kate'; 
company | name | age | role 
---------+-------+-----+------ 
A | mario | 38 | SM 
A | neno | 32 | DEV
Primary key 
PRIMARY KEY (a, b) 
PRIMARY KEY ((x, y), z, w) 
Partition Key (row) – just the 1st 
Clustering Columns – the rest
One to Many 
Users 
CREATE TABLE users ( 
username text, 
first_name text, 
last_name text, 
email text, 
PRIMARY KEY (username) 
);
One to Many 
Videos 
CREATE TABLE videos ( 
video_id uuid, 
video_name text, 
username text, 
description text, 
tags text, 
upload_date timestamp, 
PRIMARY KEY (video_id) 
);
One to Many 
User videos 
CREATE TABLE username_video_ind ( 
username text, 
video_id uuid, 
upload_date timestamp, 
video_name text, 
PRIMARY KEY (username, video_id) 
);
Many to Many 
Comments 
CREATE TABLE comments_by_video ( 
video_id uuid, 
username text, 
comment_time timestamp, 
comment text, 
PRIMARY KEY (video_id, username) 
); 
CREATE TABLE comments_by_user ( 
username text, 
videoid uuid, 
comment_time timestamp, 
comment text, 
PRIMARY KEY (username, videoid) 
);
Reverse ordering 
CREATE TABLE credit_transaction ( 
username text, 
type text, 
date_time timestamp, 
credits int, 
PRIMARY KEY (username, datetime, type) 
) WITH CLUSTERING ORDER BY 
(datetime DESC, type ASC);
Q & A 
Thank you! 
Don’t be afraid of writes! 
Join Zagreb Cassandra Users! 
@msvaljek 
msvaljek@gmail.com

Contenu connexe

Similaire à Javantura v2 - Data modeling with Apapche Cassandra - Marko Švaljek

DataStax: Old Dogs, New Tricks. Teaching your Relational DBA to fetch
DataStax: Old Dogs, New Tricks. Teaching your Relational DBA to fetchDataStax: Old Dogs, New Tricks. Teaching your Relational DBA to fetch
DataStax: Old Dogs, New Tricks. Teaching your Relational DBA to fetchDataStax Academy
 
Database queries
Database queriesDatabase queries
Database querieslaiba29012
 
DOAN DuyHai – Cassandra: real world best use-cases and worst anti-patterns - ...
DOAN DuyHai – Cassandra: real world best use-cases and worst anti-patterns - ...DOAN DuyHai – Cassandra: real world best use-cases and worst anti-patterns - ...
DOAN DuyHai – Cassandra: real world best use-cases and worst anti-patterns - ...NoSQLmatters
 
SQL DDL: tricks and tips (JProf#27, Minsk, 24th September)
SQL DDL: tricks and tips (JProf#27, Minsk, 24th September)SQL DDL: tricks and tips (JProf#27, Minsk, 24th September)
SQL DDL: tricks and tips (JProf#27, Minsk, 24th September)Mikalai Sitsko
 
lec02-data-models-sql-basics.pptx
lec02-data-models-sql-basics.pptxlec02-data-models-sql-basics.pptx
lec02-data-models-sql-basics.pptxcAnhTrn53
 
Importing Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflowImporting Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflowNeo4j
 
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...Citus Data
 
Sql vs no sql and azure data factory glasgow data UG
Sql vs no sql and azure data factory  glasgow data UGSql vs no sql and azure data factory  glasgow data UG
Sql vs no sql and azure data factory glasgow data UGDiponkar Paul
 
Heart of Data Modeling Webinar: The Ticking Timebombs in Your Data Model
Heart of Data Modeling Webinar: The Ticking Timebombs in Your Data ModelHeart of Data Modeling Webinar: The Ticking Timebombs in Your Data Model
Heart of Data Modeling Webinar: The Ticking Timebombs in Your Data ModelDATAVERSITY
 
Slide presentation pycassa_upload
Slide presentation pycassa_uploadSlide presentation pycassa_upload
Slide presentation pycassa_uploadRajini Ramesh
 
•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdfjyothimuppasani1
 
Vienna Feb 2015: Cassandra: How it works and what it's good for!
Vienna Feb 2015: Cassandra: How it works and what it's good for!Vienna Feb 2015: Cassandra: How it works and what it's good for!
Vienna Feb 2015: Cassandra: How it works and what it's good for!Christopher Batey
 
Cassandra Day Denver 2014: A Cassandra Data Model for Serving up Cat Videos
Cassandra Day Denver 2014: A Cassandra Data Model for Serving up Cat VideosCassandra Day Denver 2014: A Cassandra Data Model for Serving up Cat Videos
Cassandra Day Denver 2014: A Cassandra Data Model for Serving up Cat VideosDataStax Academy
 
Baton rouge - sql vs no sql and azure data factory
Baton rouge - sql vs no sql and azure data factoryBaton rouge - sql vs no sql and azure data factory
Baton rouge - sql vs no sql and azure data factoryDiponkar Paul
 
SQL vs. NoSQL and Moving data by Azure Data Factory
SQL vs. NoSQL and Moving data by Azure Data FactorySQL vs. NoSQL and Moving data by Azure Data Factory
SQL vs. NoSQL and Moving data by Azure Data FactoryDiponkar Paul
 
Jan 2015 - Cassandra101 Manchester Meetup
Jan 2015 - Cassandra101 Manchester MeetupJan 2015 - Cassandra101 Manchester Meetup
Jan 2015 - Cassandra101 Manchester MeetupChristopher Batey
 
Real data models of silicon valley
Real data models of silicon valleyReal data models of silicon valley
Real data models of silicon valleyPatrick McFadin
 
Data Modeling IoT and Time Series data in NoSQL
Data Modeling IoT and Time Series data in NoSQLData Modeling IoT and Time Series data in NoSQL
Data Modeling IoT and Time Series data in NoSQLBasho Technologies
 

Similaire à Javantura v2 - Data modeling with Apapche Cassandra - Marko Švaljek (20)

DataStax: Old Dogs, New Tricks. Teaching your Relational DBA to fetch
DataStax: Old Dogs, New Tricks. Teaching your Relational DBA to fetchDataStax: Old Dogs, New Tricks. Teaching your Relational DBA to fetch
DataStax: Old Dogs, New Tricks. Teaching your Relational DBA to fetch
 
Database queries
Database queriesDatabase queries
Database queries
 
DOAN DuyHai – Cassandra: real world best use-cases and worst anti-patterns - ...
DOAN DuyHai – Cassandra: real world best use-cases and worst anti-patterns - ...DOAN DuyHai – Cassandra: real world best use-cases and worst anti-patterns - ...
DOAN DuyHai – Cassandra: real world best use-cases and worst anti-patterns - ...
 
SQL DDL: tricks and tips (JProf#27, Minsk, 24th September)
SQL DDL: tricks and tips (JProf#27, Minsk, 24th September)SQL DDL: tricks and tips (JProf#27, Minsk, 24th September)
SQL DDL: tricks and tips (JProf#27, Minsk, 24th September)
 
Les09
Les09Les09
Les09
 
Apache Cassandra & Data Modeling
Apache Cassandra & Data ModelingApache Cassandra & Data Modeling
Apache Cassandra & Data Modeling
 
lec02-data-models-sql-basics.pptx
lec02-data-models-sql-basics.pptxlec02-data-models-sql-basics.pptx
lec02-data-models-sql-basics.pptx
 
Importing Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflowImporting Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflow
 
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
 
Sql vs no sql and azure data factory glasgow data UG
Sql vs no sql and azure data factory  glasgow data UGSql vs no sql and azure data factory  glasgow data UG
Sql vs no sql and azure data factory glasgow data UG
 
Heart of Data Modeling Webinar: The Ticking Timebombs in Your Data Model
Heart of Data Modeling Webinar: The Ticking Timebombs in Your Data ModelHeart of Data Modeling Webinar: The Ticking Timebombs in Your Data Model
Heart of Data Modeling Webinar: The Ticking Timebombs in Your Data Model
 
Slide presentation pycassa_upload
Slide presentation pycassa_uploadSlide presentation pycassa_upload
Slide presentation pycassa_upload
 
•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf
 
Vienna Feb 2015: Cassandra: How it works and what it's good for!
Vienna Feb 2015: Cassandra: How it works and what it's good for!Vienna Feb 2015: Cassandra: How it works and what it's good for!
Vienna Feb 2015: Cassandra: How it works and what it's good for!
 
Cassandra Day Denver 2014: A Cassandra Data Model for Serving up Cat Videos
Cassandra Day Denver 2014: A Cassandra Data Model for Serving up Cat VideosCassandra Day Denver 2014: A Cassandra Data Model for Serving up Cat Videos
Cassandra Day Denver 2014: A Cassandra Data Model for Serving up Cat Videos
 
Baton rouge - sql vs no sql and azure data factory
Baton rouge - sql vs no sql and azure data factoryBaton rouge - sql vs no sql and azure data factory
Baton rouge - sql vs no sql and azure data factory
 
SQL vs. NoSQL and Moving data by Azure Data Factory
SQL vs. NoSQL and Moving data by Azure Data FactorySQL vs. NoSQL and Moving data by Azure Data Factory
SQL vs. NoSQL and Moving data by Azure Data Factory
 
Jan 2015 - Cassandra101 Manchester Meetup
Jan 2015 - Cassandra101 Manchester MeetupJan 2015 - Cassandra101 Manchester Meetup
Jan 2015 - Cassandra101 Manchester Meetup
 
Real data models of silicon valley
Real data models of silicon valleyReal data models of silicon valley
Real data models of silicon valley
 
Data Modeling IoT and Time Series data in NoSQL
Data Modeling IoT and Time Series data in NoSQLData Modeling IoT and Time Series data in NoSQL
Data Modeling IoT and Time Series data in NoSQL
 

Plus de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association

Plus de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association (20)

Java cro'21 the best tools for java developers in 2021 - hujak
Java cro'21   the best tools for java developers in 2021 - hujakJava cro'21   the best tools for java developers in 2021 - hujak
Java cro'21 the best tools for java developers in 2021 - hujak
 
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK KeynoteJavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
 
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan LozićJavantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
 
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
 
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
 
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
 
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander RadovanJavantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
 
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
 
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
 
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
 
Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...
 
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej VidakovićJavantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
 
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
 
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
 
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
 
Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...
 
Javantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela PetracJavantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela Petrac
 
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje RuhekJavantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
 
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
 
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario KusekJavantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
 

Dernier

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Dernier (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Javantura v2 - Data modeling with Apapche Cassandra - Marko Švaljek

  • 1. Data modeling with Apache Cassandra Marko Švaljek @msvaljek
  • 2. About me • Software Developer at Kapsch • Zagreb Cassandra Meetup
  • 3. About Cassandra • Written in Java • Wide Row Store • Masterless • DataStax
  • 4. About Cassandra • No Single Point of failure ✓ • Cross Datacenter ✓ • Linear Scaling ✓ • Data modeling ?
  • 5. Data Model • Highly denormalized • No foreign keys • No referential integrity • No joins
  • 6. Compared to Relational • Think about the questions up front • No penalty for wide rows • Disk is cheap • Bring on the writes
  • 7. Cassandra Objects • Keyspace (database) • Table • Primary key • Index
  • 10. CQL • Cassandra Query Language • Similar to SQL • Learning curve • No code reading
  • 11. Create table CREATE TABLE employees ( name text PRIMARY KEY, age int, role text );
  • 12. Inserting INSERT INTO employees (name, age) VALUES ('mario', 38); INSERT INTO employees (name, age) VALUES ('tom', 24);
  • 13. Selecting SELECT * FROM employees; name | age | role -------+-----+------ tom | 24 | DEV mario | 38 | SM
  • 14. Hmm … SELECT * FROM employees WHERE age > 20; Bad Request: No indexed columns present in by-columns clause with Equal operator
  • 15. How it’s stored • Every row is a partition • There is no “next” row
  • 16. Primary key CREATE TABLE employees2 ( company text, name text, age int, role text, PRIMARY KEY (company, name) );
  • 17. Primary key company | name | age | role ---------+-------+-----+------ B | john | 25 | DEV B | peter | 22 | DEV A | kate | 33 | PM A | mario | 38 | SM A | neno | 32 | DEV PRIMARY KEY (company, name)
  • 18. Primary key company | name | age | role ---------+-------+-----+------ B | john | 25 | DEV B | peter | 22 | DEV A | kate | 33 | PM A | mario | 38 | SM A | neno | 32 | DEV
  • 19. Primary key SELECT * FROM employees2 WHERE company = 'A' AND name > 'kate'; company | name | age | role ---------+-------+-----+------ A | mario | 38 | SM A | neno | 32 | DEV
  • 20. Primary key PRIMARY KEY (a, b) PRIMARY KEY ((x, y), z, w) Partition Key (row) – just the 1st Clustering Columns – the rest
  • 21. One to Many Users CREATE TABLE users ( username text, first_name text, last_name text, email text, PRIMARY KEY (username) );
  • 22. One to Many Videos CREATE TABLE videos ( video_id uuid, video_name text, username text, description text, tags text, upload_date timestamp, PRIMARY KEY (video_id) );
  • 23. One to Many User videos CREATE TABLE username_video_ind ( username text, video_id uuid, upload_date timestamp, video_name text, PRIMARY KEY (username, video_id) );
  • 24. Many to Many Comments CREATE TABLE comments_by_video ( video_id uuid, username text, comment_time timestamp, comment text, PRIMARY KEY (video_id, username) ); CREATE TABLE comments_by_user ( username text, videoid uuid, comment_time timestamp, comment text, PRIMARY KEY (username, videoid) );
  • 25. Reverse ordering CREATE TABLE credit_transaction ( username text, type text, date_time timestamp, credits int, PRIMARY KEY (username, datetime, type) ) WITH CLUSTERING ORDER BY (datetime DESC, type ASC);
  • 26. Q & A Thank you! Don’t be afraid of writes! Join Zagreb Cassandra Users! @msvaljek msvaljek@gmail.com