SlideShare a Scribd company logo
1 of 53
C a s s a n d r a
QUERY DRIVEN
DEVELOPMENT
How Cassandra influences the way we build applications.
AGENDA
2
AGENDA
• Relational Databases
• Column Family Databases
• Cassandra Concepts
• Architecture
• CQL
• Tables
• Primary Keys
• Partition Keys
• Clustering Columns
• Data Modeling
• Conceptual Model
• Application Workflow
• Logical Model
• Physical Model
• Anti-Patterns
3
RELATIONAL
DATABASES
4
RELATIONAL DATABASES
5
RELATIONAL DATABASES
A relational database is in general…
Suited for:
• Relational data (well defined domain model)
• Structured data (tabular data)
• "Small" data volume
• ACID operations (transactions)
• Ad-hoc and/or complex queries (joins)
Not suited for:
• Unstructured data
• Large data volume
• Geographically distributed users
• Scaling
• Reliability
6
COLUMN FAMILY
DATABASES
7
COLUMN FAMILY DATABASES
8
COLUMN FAMILY DATABASES
9
COLUMN FAMILY DATABASES
A column family model is in general…
Suited for:
• Structured and unstructured data
• Large data volumes
• Geographically distributed users
• Scaling
• Reliability
Not suited for:
• ACID operations (transactions)
• Ad-hoc and/or complex queries (joins)
10
CASSANDRA’S
ARCHITECTURE
11
CASSANDRA’S ARCHITECTURE
12
CASSANDRA’S ARCHITECTURE
A Cassandra cluster…
• Is a distributed system.
• Does not have a leader or master node (all nodes are equal).
• Replicates data across nodes (allows fault tolerance).
• Partitions data across nodes (allows fast writes/reads).
• Is fault tolerant.
• Is eventually consistent.
• Can be distributed across data centers.
• Is usually called a Ring.
13
CQL
14
CQL
15
CQL
CQL…
• Stands for Cassandra Query Language.
• Is similar to SQL.
• Does not support joins.
• Supports user defined types.
• Supports user defined functions.
• Supports materialized views.
16
TABLES
17
TABLES
18
TABLES
Tables in Cassandra…
• Are an abstraction.
• Are actually implemented as column families.
19
PRIMARY
KEYS
20
PRIMARY KEYS
21
PRIMARY KEYS
A primary key fulfill the following purposes…
• Uniqueness of a record within a table
• Search criteria (what columns can be used to filter the table)
22
PARTITION
KEYS
23
PARTITION KEYS
24
PARTITION KEYS
Partition keys define…
• How the data is going to be partitioned across the cluster
• Which columns require an equality search criteria
• Columns defined in the partition key must be present in the where clause of a query
25
CLUSTERING
COLUMNS
26
CLUSTERING COLUMNS
27
CLUSTERING COLUMNS
Clustering columns define…
• How the data is grouped within a partition
• The ordering of the data within the table
Clustering columns also…
• Can be used both as equality and inequality search criteria
• Are not required in a where clause.
28
DATA MODELING
29
DATA MODELING
30
DATA MODELING
Data modeling in Cassandra is composed by the following steps…
• Definition of the Conceptual Model
• Definition of the Application Workflow
• Derivation and selection of the Logical Model
• Derivation of the Physical Model
• Translation of the Physical Model into CQL scripts
Cassandra data modeling principles:
• Know your data
• Know your queries
• Nest data
• Duplicate data (denormalize)
31
CONCEPTUAL
MODEL
32
CONCEPTUAL MODEL
33
CONCEPTUAL MODEL
A conceptual model…
• Is usually described as an Entity Relationship diagram.
• Describes domain entities, its attributes and relationships.
• Enables collaboration between business and technical people.
• Allows abstraction of the implementation details.
• Facilitates understanding of the domain.
34
APPLICATION
WORKFLOW
35
APPLICATION WORKFLOW
36
APPLICATION WORKFLOW
37
APPLICATION WORKFLOW
The application workflow…
• Helps identifying tasks and its dependencies.
• Defines which queries are required by the application.
• Helps identifying which queries need to run first.
38
LOGICAL MODEL
39
LOGICAL MODEL
40
LOGICAL MODEL
A logical model…
• It’s an abstraction of the physical schema
• Identifies tables along with its columns, partition keys, clustering columns and other
metadata
• Allows us to think about the data model, partitioning and ordering, without worrying
about the implementation details.
41
LOGICAL MODEL
42
LOGICAL MODEL
Mapping Rules
• Rule 1: Entities and relationships (becomes tables)
• Rule 2: Equality search and attributes (becomes PKs)
• Rule 3: Inequality search and attributes (becomes clustering columns)
• Rule 4: Ordering attributes (defines ordering: ASC, DESC)
• Rule 5: Key attributes (guarantees record uniqueness)
43
LOGICAL MODEL
Mapping Patterns
• Entity mapping (query attribs = key attribs; query attribs != key attribs)
• 1:1 relationship mapping (query attribs = key attribs; query attributes != key attribs)
• 1:n relationship mapping
• m:n relationship mapping
• Hierarchical mapping
44
LOGICAL MODEL
45
PHYSICAL MODEL
46
PHYSICAL MODEL
47
PHYSICAL MODEL
48
PHYSICAL MODEL
The physical model…
• Is the actual implementation of the logical model
• Defines column types
• It’s where we think about optimizations
49
ANTI-PATTERNS
50
ANTI-PATTERNS
Things we should not do in Cassandra…
• Table scan (too expensive, searches the entire cluster)
• Secondary indexes (stored locally in a node, too expensive, searches the entire cluster)
• Multi-table (requires multiple look ups and joins in the client side)
• Reads before writes
51
QUESTIONS?
52
For questions or suggestions:
Contact
jsilva@thoughtworks.com
joao.dasilva@equifax.com
THANK YOU

More Related Content

Similar to Query driven development

Mc leod9e ch06 database management systems
Mc leod9e ch06 database management systemsMc leod9e ch06 database management systems
Mc leod9e ch06 database management systemssellyhood
 
No SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageNo SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageBethmi Gunasekara
 
Deep Dive : Spark Data Frames, SQL and Catalyst Optimizer
Deep Dive : Spark Data Frames, SQL and Catalyst OptimizerDeep Dive : Spark Data Frames, SQL and Catalyst Optimizer
Deep Dive : Spark Data Frames, SQL and Catalyst OptimizerSachin Aggarwal
 
Data Models - Department of Computer Science & Engineering
Data Models - Department of Computer Science & EngineeringData Models - Department of Computer Science & Engineering
Data Models - Department of Computer Science & Engineeringacemindia
 
No sql or Not only SQL
No sql or Not only SQLNo sql or Not only SQL
No sql or Not only SQLAjay Jha
 
Fundamentals of Database ppt ch03
Fundamentals of Database ppt ch03Fundamentals of Database ppt ch03
Fundamentals of Database ppt ch03Jotham Gadot
 
Chapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfChapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfTamiratDejene1
 
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...Artem Chebotko
 
Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysisRiteshkiit
 
My Query is slow, now what?
My Query is slow, now what?My Query is slow, now what?
My Query is slow, now what?Gianluca Sartori
 
Week 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxNurulIzrin
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLEDrkhanchanaR
 
Relational databases.pdf
Relational databases.pdfRelational databases.pdf
Relational databases.pdfchandiruirene
 
artificial intelligence.pptx
artificial intelligence.pptxartificial intelligence.pptx
artificial intelligence.pptxrithika858339
 
Data Mining With SQL Server
Data Mining With SQL ServerData Mining With SQL Server
Data Mining With SQL ServerHoan Phuc
 

Similar to Query driven development (20)

Mc leod9e ch06 database management systems
Mc leod9e ch06 database management systemsMc leod9e ch06 database management systems
Mc leod9e ch06 database management systems
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
 
No SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageNo SQL- The Future Of Data Storage
No SQL- The Future Of Data Storage
 
Deep Dive : Spark Data Frames, SQL and Catalyst Optimizer
Deep Dive : Spark Data Frames, SQL and Catalyst OptimizerDeep Dive : Spark Data Frames, SQL and Catalyst Optimizer
Deep Dive : Spark Data Frames, SQL and Catalyst Optimizer
 
Data Models - Department of Computer Science & Engineering
Data Models - Department of Computer Science & EngineeringData Models - Department of Computer Science & Engineering
Data Models - Department of Computer Science & Engineering
 
No sql or Not only SQL
No sql or Not only SQLNo sql or Not only SQL
No sql or Not only SQL
 
Fundamentals of Database ppt ch03
Fundamentals of Database ppt ch03Fundamentals of Database ppt ch03
Fundamentals of Database ppt ch03
 
Chapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdfChapter – 2 Data Models.pdf
Chapter – 2 Data Models.pdf
 
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
 
Statistics and Indexes Internals
Statistics and Indexes InternalsStatistics and Indexes Internals
Statistics and Indexes Internals
 
Different data models
Different data modelsDifferent data models
Different data models
 
Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysis
 
My Query is slow, now what?
My Query is slow, now what?My Query is slow, now what?
My Query is slow, now what?
 
Java JDBC
Java JDBCJava JDBC
Java JDBC
 
Week 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptx
 
Unit I Database concepts - RDBMS & ORACLE
Unit I  Database concepts - RDBMS & ORACLEUnit I  Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
 
Relational databases.pdf
Relational databases.pdfRelational databases.pdf
Relational databases.pdf
 
artificial intelligence.pptx
artificial intelligence.pptxartificial intelligence.pptx
artificial intelligence.pptx
 
Data Mining With SQL Server
Data Mining With SQL ServerData Mining With SQL Server
Data Mining With SQL Server
 
NoSql Brownbag
NoSql BrownbagNoSql Brownbag
NoSql Brownbag
 

More from João Paulo Leonidas Fernandes Dias da Silva (7)

Apache spark intro
Apache spark introApache spark intro
Apache spark intro
 
Kafka basics
Kafka basicsKafka basics
Kafka basics
 
Recommender Systems
Recommender SystemsRecommender Systems
Recommender Systems
 
OpenCL Heterogeneous Parallel Computing
OpenCL Heterogeneous Parallel ComputingOpenCL Heterogeneous Parallel Computing
OpenCL Heterogeneous Parallel Computing
 
Apache Storm Basics
Apache Storm BasicsApache Storm Basics
Apache Storm Basics
 
Unit testing basics
Unit testing basicsUnit testing basics
Unit testing basics
 
Qcon Rio 2015 - Data Lakes Workshop
Qcon Rio 2015 - Data Lakes WorkshopQcon Rio 2015 - Data Lakes Workshop
Qcon Rio 2015 - Data Lakes Workshop
 

Recently uploaded

100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 

Recently uploaded (20)

100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 

Query driven development