SlideShare a Scribd company logo
1 of 102
Download to read offline
DSE Graph Fundamentals
Jon Haddad, DataStax
Technical Evangelist
@rustyrazorblade
© DataStax, All Rights Reserved.
A Quick Look at Relational
2
© DataStax, All Rights Reserved.
Tables
• Very structured data
• Relational calculus
• Various normal forms
3
id name title country
1 jon evangelist usa
2 patrick chief	evangelist usa
3 rebecca jr	evangelist canada
4 billy ceo usa
© DataStax, All Rights Reserved.
Selecting and Filtering
4
id name title country
1 jon evangelist usa
2 patrick chief	evangelist usa
3 rebecca jr	evangelist canada
4 billy ceo usa
© DataStax, All Rights Reserved.
Selecting and Filtering
4
id name title country
1 jon evangelist usa
2 patrick chief	evangelist usa
3 rebecca jr	evangelist canada
4 billy ceo usa
select * from people where country = 'canada';
© DataStax, All Rights Reserved.
Selecting and Filtering
4
id name title country
1 jon evangelist usa
2 patrick chief	evangelist usa
3 rebecca jr	evangelist canada
4 billy ceo usa
select * from people where country = 'canada';
© DataStax, All Rights Reserved.
Foreign Keys
5
id name title country
1 jon evangelist 1
2 patrick chief	evangelist 1
3 rebecca jr	evangelist 2
4 billy ceo 1
id name
1 usa
2 canada
3 germany
4 japan
© DataStax, All Rights Reserved.
Foreign Keys
5
id name title country
1 jon evangelist 1
2 patrick chief	evangelist 1
3 rebecca jr	evangelist 2
4 billy ceo 1
id name
1 usa
2 canada
3 germany
4 japan
© DataStax, All Rights Reserved.
Foreign Keys
5
id name title country
1 jon evangelist 1
2 patrick chief	evangelist 1
3 rebecca jr	evangelist 2
4 billy ceo 1
id name
1 usa
2 canada
3 germany
4 japan
© DataStax, All Rights Reserved.
Joins
6
select * from people join country on
people.country = country.id;
id name title country name
1 jon evangelist 1 usa
2 patrick chief	evangelist 1 usa
3 rebecca jr	evangelist 2 canada
4 billy ceo 1 usa
© DataStax, All Rights Reserved.
Many to Many Relationships
7
id name title
1 jon evangelist
2 patrick chief	evangelist
3 rebecca jr	evangelist
4 billy ceo
id name
1 usa
2 canada
3 germany
4 japan
user country
1 1
1 2
2 1
3 2
4 1
© DataStax, All Rights Reserved.
Many to Many Relationships
7
id name title
1 jon evangelist
2 patrick chief	evangelist
3 rebecca jr	evangelist
4 billy ceo
id name
1 usa
2 canada
3 germany
4 japan
user country
1 1
1 2
2 1
3 2
4 1
© DataStax, All Rights Reserved.
Many to Many Relationships
7
id name title
1 jon evangelist
2 patrick chief	evangelist
3 rebecca jr	evangelist
4 billy ceo
id name
1 usa
2 canada
3 germany
4 japan
user country
1 1
1 2
2 1
3 2
4 1
© DataStax, All Rights Reserved.
Many to Many Relationships
7
id name title
1 jon evangelist
2 patrick chief	evangelist
3 rebecca jr	evangelist
4 billy ceo
id name
1 usa
2 canada
3 germany
4 japan
user country
1 1
1 2
2 1
3 2
4 1
© DataStax, All Rights Reserved.
Many to Many Relationships
7
id name title
1 jon evangelist
2 patrick chief	evangelist
3 rebecca jr	evangelist
4 billy ceo
id name
1 usa
2 canada
3 germany
4 japan
user country
1 1
1 2
2 1
3 2
4 1
© DataStax, All Rights Reserved.
Joining
8
select * from people
join people_country on people.id = people_country.user
join country on people_country.country = country.id;
id name title country name
1 jon evangelist 1 usa
1 jon evangelist 2 canada
2 patrick chief	evangelist 1 usa
3 rebecca jr	evangelist 2 canada
4 billy ceo 1 usa
© DataStax, All Rights Reserved.
Joining
8
select * from people
join people_country on people.id = people_country.user
join country on people_country.country = country.id;
id name title country name
1 jon evangelist 1 usa
1 jon evangelist 2 canada
2 patrick chief	evangelist 1 usa
3 rebecca jr	evangelist 2 canada
4 billy ceo 1 usa
© DataStax, All Rights Reserved.
A Fun, Real World Example
9
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
person
id
name
dob
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
person
id
name
dob
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
actor_movie
person
movie
role
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
actor_movie
person
movie
role
actor_tv
person
tv_show
dob
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
actor_movie
person
movie
role
actor_tv
person
tv_show
dob
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
actor_movie
person
movie
role
actor_tv
person
tv_show
dob
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
actor_movie
person
movie
role
actor_tv
person
tv_show
dob
episode
tv_show
season
episode
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
actor_movie
person
movie
role
actor_tv
person
tv_show
dob
episode
tv_show
season
episode
actor_episode
episode
actor
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
actor_movie
person
movie
role
actor_tv
person
tv_show
dob
episode
tv_show
season
episode
actor_episode
episode
actor
© DataStax, All Rights Reserved.
Media Database
1. People - actors, directories, assistants
2. Movies, TV, episodes
10
movie
id
name
year
tv_show
id
name
person
id
name
dob
actor_movie
person
movie
role
actor_tv
person
tv_show
dob
episode
tv_show
season
episode
actor_episode
episode
actor
© DataStax, All Rights Reserved.
Problems
• Every entity gets a table
• Lots of many to many tables
• Very rigid structure
• Going from one to many
requires a migration and new
data model
11
© DataStax, All Rights Reserved.
Problems
• Every entity gets a table
• Lots of many to many tables
• Very rigid structure
• Going from one to many
requires a migration and new
data model
11
© DataStax, All Rights Reserved.
How is this Solved with a Graph?
12
© DataStax, All Rights Reserved.
Vertex
• A vertex represents a "thing"
• For example: Movie, Person
13
© DataStax, All Rights Reserved.
Vertex
• A vertex represents a "thing"
• For example: Movie, Person
13
JCVD
© DataStax, All Rights Reserved.
Vertex
• A vertex represents a "thing"
• For example: Movie, Person
13
JCVD
Time
cop
© DataStax, All Rights Reserved.
JCVD
Time
cop
Edge
• Edges are labeled relationships
• Edges have direction
14
© DataStax, All Rights Reserved.
JCVD
Time
cop
Edge
• Edges are labeled relationships
• Edges have direction
14
ActedIn
© DataStax, All Rights Reserved.
Edges are always many to many
15
JCVD
Time
cop
Blood
sport
© DataStax, All Rights Reserved.
Edges are always many to many
15
JCVD
Time
copActedIn
Blood
sport
© DataStax, All Rights Reserved.
Edges are always many to many
15
JCVD
Time
copActedIn
Blood
sport
ActedIn
© DataStax, All Rights Reserved.
Edges are always many to many
15
JCVD
Time
copActedIn
Blood
sport
ActedIn
Directed
© DataStax, All Rights Reserved.
The power of graph?
16
© DataStax, All Rights Reserved.
Relationships
17
© DataStax, All Rights Reserved.
Let's build on that
18
© DataStax, All Rights Reserved.
Properties
• Similar to fields in a table
• Much more flexible
• Meta properties - properties on properties
• Can be on an edge or a vertex
• Special property - a label
19
JCVD
status amazing
charm infinite
odds	of	rendezvous 99.6%
enemies	decapitated 108747
© DataStax, All Rights Reserved.
Summary
1. We don't define tables
2. We create vertices to represent real
world objects
3. Relationships don't need to be
explicitly modeled
4. Expressing complex relationships is
not hard
5. Adding new edge types is easy
20
© DataStax, All Rights Reserved.
Tinkerpop 3 & Gremlin
• Cross database graph query framework
• API for graph
21
© DataStax, All Rights Reserved.
TinkerPop Basics
22
© DataStax, All Rights Reserved.
Create a Vertex
23
graph.createVertex(label,	"person",		
								"name",	"Jean	Claude	Van	Damme")
graph.createVertex(label,	"movie",		
								"name",	"Bloodsport")
© DataStax, All Rights Reserved.
Traversals
24
g	=	graph.traversal()
g.V()
© DataStax, All Rights Reserved.
Finding Vertices
25
g.V().has("person",	"name",	"Jean	Claude	van	Damme")
© DataStax, All Rights Reserved.
Finding Vertices
25
g.V().has("person",	"name",	"Jean	Claude	van	Damme")
© DataStax, All Rights Reserved.
Finding Vertices
25
g.V().has("person",	"name",	"Jean	Claude	van	Damme")
© DataStax, All Rights Reserved.
Finding Vertices
25
g.V().has("person",	"name",	"Jean	Claude	van	Damme")
© DataStax, All Rights Reserved.
Finding Vertices
25
g.V().has("person",	"name",	"Jean	Claude	van	Damme")
© DataStax, All Rights Reserved.
Create an Edge
26
g.V().has('person',	'name',	"Jean	Claude	Van	Damme").as('a').	
		V().has('movie',	'name',	"Bloodsport").as('b').	
						addE("acted_in").property('year',	1988).	
							from("a").to("b")
© DataStax, All Rights Reserved.
Traversals
27
jcvd	=	g.V().has('person','name',	"Jean	Claude	Van	Damme")
© DataStax, All Rights Reserved.
Traversals to neighbors
28
Bloodsport (1988)
Kickboxer (1989)
Timecop (1994)jcvd.out()
© DataStax, All Rights Reserved.
Traversals to neighbors
28
Bloodsport (1988)
Kickboxer (1989)
Timecop (1994)jcvd.out()
© DataStax, All Rights Reserved.
Traversals to neighbors
28
Bloodsport (1988)
Kickboxer (1989)
Timecop (1994)jcvd.out()
© DataStax, All Rights Reserved.
Traversals to edges
29
Bloodsport (1988)
Kickboxer (1989)
Timecop (1994)
jcvd.outE()
© DataStax, All Rights Reserved.
Traversals to edges
29
Bloodsport (1988)
Kickboxer (1989)
Timecop (1994)
jcvd.outE()
© DataStax, All Rights Reserved.
Who cares?
30
© DataStax, All Rights Reserved. 31
SELECT	movie.name	from	person		
		JOIN	roles	on	person.id	=	roles.person	
		JOIN	movies	on	roles.movie	=	movies.id	
WHERE	person.name	=	"Jean	Claude	Van	Damme"
© DataStax, All Rights Reserved. 32
jcvd.out("acted_in")
© DataStax, All Rights Reserved. 33
© DataStax, All Rights Reserved. 33
NO
© DataStax, All Rights Reserved. 34
jcvd.out("acted_in",	"directed")
© DataStax, All Rights Reserved. 35
SELECT	movies.name	from	person		
		JOIN	roles	on	person.id	=	roles.person	
		JOIN	movies	on	roles.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	directed	on	person.id	=	directed.person	
		JOIN	movies	on	directed.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"
© DataStax, All Rights Reserved.
SELECT	movies.name	from	person		
		JOIN	roles	on	person.id	=	roles.person	
		JOIN	movies	on	roles.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	directed	on	person.id	=	directed.person	
		JOIN	movies	on	directed.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	produced	on	person.id	=	produced.person	
		JOIN	movies	on	produced.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	stage_hand	on	person.id	=	stage_hand.person	
		JOIN	movies	on	stage_hand.movie	=	movies.id
© DataStax, All Rights Reserved.
SELECT	movies.name	from	person		
		JOIN	directed	on	person.id	=	directed.person	
		JOIN	movies	on	directed.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	produced	on	person.id	=	produced.person	
		JOIN	movies	on	produced.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	stage_hand	on	person.id	=	stage_hand.person	
		JOIN	movies	on	stage_hand.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	stage_hand	on	person.id	=	stage_hand.person	
		JOIN	movies	on	stage_hand.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"
© DataStax, All Rights Reserved.
SELECT	movies.name	from	person		
		JOIN	directed	on	person.id	=	directed.person	
		JOIN	movies	on	directed.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	produced	on	person.id	=	produced.person	
		JOIN	movies	on	produced.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	stage_hand	on	person.id	=	stage_hand.person	
		JOIN	movies	on	stage_hand.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"	
UNION	
SELECT	movies.name	from	person		
		JOIN	stage_hand	on	person.id	=	stage_hand.person	
		JOIN	movies	on	stage_hand.movie	=	movies.id	
WHERE	actor.name	=	"Jean	Claude	Van	Damme"
© DataStax, All Rights Reserved. 37
jcvd.out()
© DataStax, All Rights Reserved.
Who acted with Van Damme
and was born in Texas?
38
© DataStax, All Rights Reserved.
Traversals
39
jcvd.out("acted_in")
jcvd
acted_in
acted_in
time	cop
bloodsport
© DataStax, All Rights Reserved.
Traversals
39
jcvd.out("acted_in")
jcvd
acted_in
acted_in
.in("acted_in")
time	cop
bloodsport
© DataStax, All Rights Reserved.
Traversals
39
jcvd.out("acted_in")
jcvd
acted_in
acted_in
.in("acted_in")
ron	
silveracted_in
Bruce	
McGill
acted_in
Forest	
Whitaker
acted_in
New	York
Texas
Texas
time	cop
bloodsport
© DataStax, All Rights Reserved.
Traversals
39
jcvd.out("acted_in")
jcvd
acted_in
acted_in
.in("acted_in")
ron	
silveracted_in
Bruce	
McGill
acted_in
Forest	
Whitaker
acted_in
New	York
Texas
Texas
time	cop
bloodsport
© DataStax, All Rights Reserved.
Traversals
39
jcvd.out("acted_in")
jcvd
acted_in
acted_in
	.has("state_of_birth",	"Texas")
.in("acted_in")
ron	
silveracted_in
Bruce	
McGill
acted_in
Forest	
Whitaker
acted_in
New	York
Texas
Texas
time	cop
bloodsport
© DataStax, All Rights Reserved.
Traversals
39
jcvd.out("acted_in")
jcvd
acted_in
acted_in
	.has("state_of_birth",	"Texas")
.in("acted_in")
ron	
silveracted_in
Bruce	
McGill
acted_in
Forest	
Whitaker
acted_in
New	York
Texas
Texas
time	cop
bloodsport
© DataStax, All Rights Reserved.
Creating Indexes
40
schema.vertexLabel('person').index('by_year_born')	
	.materialized().by('year_born').add()	
schema.vertexLabel('person').index('search').	
	search().by('biography').asText().add()
© DataStax, All Rights Reserved.
Creating Indexes
40
schema.vertexLabel('person').index('by_year_born')	
	.materialized().by('year_born').add()	
schema.vertexLabel('person').index('search').	
	search().by('biography').asText().add()
© DataStax, All Rights Reserved.
Creating Indexes
40
schema.vertexLabel('person').index('by_year_born')	
	.materialized().by('year_born').add()	
schema.vertexLabel('person').index('search').	
	search().by('biography').asText().add()
© DataStax, All Rights Reserved.
Who has ANY relationship with any actor born in 1920?
41
g.V().has("person",	"year_born",	1920).	
						out("acted_in").in().hasLabel("person")
© DataStax, All Rights Reserved.
index	selection
Who has ANY relationship with any actor born in 1920?
41
g.V().has("person",	"year_born",	1920).	
						out("acted_in").in().hasLabel("person")
© DataStax, All Rights Reserved.
Who has ANY relationship with any actor born in 1920?
41
g.V().has("person",	"year_born",	1920).	
						out("acted_in").in().hasLabel("person")
unconstrained	relationships	with	no	foreign	keys
© DataStax, All Rights Reserved.
How do I know Patrick?
42
© DataStax, All Rights Reserved.
Path Finding!
43
© DataStax, All Rights Reserved. 44
jon	=	g.V().has("nickname",	"rustyrazorblade")	
jon.until(has("nickname",	"PatrickMcFadin")).	
				repeat(both())
© DataStax, All Rights Reserved.
My cousin went to school with Patrick
45
@rustyrazorblade
@PatrickMcfadin
© DataStax, All Rights Reserved.
My cousin went to school with Patrick
45
@rustyrazorblade
@PatrickMcfadin
cousin
@oscar_the_grouch
© DataStax, All Rights Reserved.
My cousin went to school with Patrick
45
@rustyrazorblade
@PatrickMcfadin
cousin
@oscar_the_grouch
attended
Cal	Poly
© DataStax, All Rights Reserved.
My cousin went to school with Patrick
45
attended
@rustyrazorblade
@PatrickMcfadin
cousin
@oscar_the_grouch
attended
Cal	Poly
© DataStax, All Rights Reserved.
We have a mutual friend in the same company
46
© DataStax, All Rights Reserved.
We have a mutual friend in the same company
46
friend
© DataStax, All Rights Reserved.
We have a mutual friend in the same company
46
friend
works_at
© DataStax, All Rights Reserved.
We have a mutual friend in the same company
46
friend
works_at
works_at
© DataStax, All Rights Reserved.
When do you use graph?
47
© DataStax, All Rights Reserved.
Graph helps solves complex
problems by utilizing of the
power of relationships
48
© DataStax, All Rights Reserved. 49
© DataStax, All Rights Reserved. 49
Thank	you!!!

More Related Content

More from DataStax

Is Your Enterprise Ready to Shine This Holiday Season?
Is Your Enterprise Ready to Shine This Holiday Season?Is Your Enterprise Ready to Shine This Holiday Season?
Is Your Enterprise Ready to Shine This Holiday Season?DataStax
 
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...DataStax
 
Running DataStax Enterprise in VMware Cloud and Hybrid Environments
Running DataStax Enterprise in VMware Cloud and Hybrid EnvironmentsRunning DataStax Enterprise in VMware Cloud and Hybrid Environments
Running DataStax Enterprise in VMware Cloud and Hybrid EnvironmentsDataStax
 
Best Practices for Getting to Production with DataStax Enterprise Graph
Best Practices for Getting to Production with DataStax Enterprise GraphBest Practices for Getting to Production with DataStax Enterprise Graph
Best Practices for Getting to Production with DataStax Enterprise GraphDataStax
 
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step JourneyWebinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step JourneyDataStax
 
Webinar | How to Understand Apache Cassandra™ Performance Through Read/Writ...
Webinar  |  How to Understand Apache Cassandra™ Performance Through Read/Writ...Webinar  |  How to Understand Apache Cassandra™ Performance Through Read/Writ...
Webinar | How to Understand Apache Cassandra™ Performance Through Read/Writ...DataStax
 
Webinar | Better Together: Apache Cassandra and Apache Kafka
Webinar  |  Better Together: Apache Cassandra and Apache KafkaWebinar  |  Better Together: Apache Cassandra and Apache Kafka
Webinar | Better Together: Apache Cassandra and Apache KafkaDataStax
 
Top 10 Best Practices for Apache Cassandra and DataStax Enterprise
Top 10 Best Practices for Apache Cassandra and DataStax EnterpriseTop 10 Best Practices for Apache Cassandra and DataStax Enterprise
Top 10 Best Practices for Apache Cassandra and DataStax EnterpriseDataStax
 
Introduction to Apache Cassandra™ + What’s New in 4.0
Introduction to Apache Cassandra™ + What’s New in 4.0Introduction to Apache Cassandra™ + What’s New in 4.0
Introduction to Apache Cassandra™ + What’s New in 4.0DataStax
 
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...DataStax
 
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
Webinar  |  Aligning GDPR Requirements with Today's Hybrid Cloud RealitiesWebinar  |  Aligning GDPR Requirements with Today's Hybrid Cloud Realities
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud RealitiesDataStax
 
Designing a Distributed Cloud Database for Dummies
Designing a Distributed Cloud Database for DummiesDesigning a Distributed Cloud Database for Dummies
Designing a Distributed Cloud Database for DummiesDataStax
 
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
How to Power Innovation with Geo-Distributed Data Management in Hybrid CloudHow to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
How to Power Innovation with Geo-Distributed Data Management in Hybrid CloudDataStax
 
How to Evaluate Cloud Databases for eCommerce
How to Evaluate Cloud Databases for eCommerceHow to Evaluate Cloud Databases for eCommerce
How to Evaluate Cloud Databases for eCommerceDataStax
 
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...DataStax
 
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...DataStax
 
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...DataStax
 
Datastax - The Architect's guide to customer experience (CX)
Datastax - The Architect's guide to customer experience (CX)Datastax - The Architect's guide to customer experience (CX)
Datastax - The Architect's guide to customer experience (CX)DataStax
 
An Operational Data Layer is Critical for Transformative Banking Applications
An Operational Data Layer is Critical for Transformative Banking ApplicationsAn Operational Data Layer is Critical for Transformative Banking Applications
An Operational Data Layer is Critical for Transformative Banking ApplicationsDataStax
 
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design ThinkingBecoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design ThinkingDataStax
 

More from DataStax (20)

Is Your Enterprise Ready to Shine This Holiday Season?
Is Your Enterprise Ready to Shine This Holiday Season?Is Your Enterprise Ready to Shine This Holiday Season?
Is Your Enterprise Ready to Shine This Holiday Season?
 
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
Designing Fault-Tolerant Applications with DataStax Enterprise and Apache Cas...
 
Running DataStax Enterprise in VMware Cloud and Hybrid Environments
Running DataStax Enterprise in VMware Cloud and Hybrid EnvironmentsRunning DataStax Enterprise in VMware Cloud and Hybrid Environments
Running DataStax Enterprise in VMware Cloud and Hybrid Environments
 
Best Practices for Getting to Production with DataStax Enterprise Graph
Best Practices for Getting to Production with DataStax Enterprise GraphBest Practices for Getting to Production with DataStax Enterprise Graph
Best Practices for Getting to Production with DataStax Enterprise Graph
 
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step JourneyWebinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
Webinar | Data Management for Hybrid and Multi-Cloud: A Four-Step Journey
 
Webinar | How to Understand Apache Cassandra™ Performance Through Read/Writ...
Webinar  |  How to Understand Apache Cassandra™ Performance Through Read/Writ...Webinar  |  How to Understand Apache Cassandra™ Performance Through Read/Writ...
Webinar | How to Understand Apache Cassandra™ Performance Through Read/Writ...
 
Webinar | Better Together: Apache Cassandra and Apache Kafka
Webinar  |  Better Together: Apache Cassandra and Apache KafkaWebinar  |  Better Together: Apache Cassandra and Apache Kafka
Webinar | Better Together: Apache Cassandra and Apache Kafka
 
Top 10 Best Practices for Apache Cassandra and DataStax Enterprise
Top 10 Best Practices for Apache Cassandra and DataStax EnterpriseTop 10 Best Practices for Apache Cassandra and DataStax Enterprise
Top 10 Best Practices for Apache Cassandra and DataStax Enterprise
 
Introduction to Apache Cassandra™ + What’s New in 4.0
Introduction to Apache Cassandra™ + What’s New in 4.0Introduction to Apache Cassandra™ + What’s New in 4.0
Introduction to Apache Cassandra™ + What’s New in 4.0
 
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
Webinar: How Active Everywhere Database Architecture Accelerates Hybrid Cloud...
 
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
Webinar  |  Aligning GDPR Requirements with Today's Hybrid Cloud RealitiesWebinar  |  Aligning GDPR Requirements with Today's Hybrid Cloud Realities
Webinar | Aligning GDPR Requirements with Today's Hybrid Cloud Realities
 
Designing a Distributed Cloud Database for Dummies
Designing a Distributed Cloud Database for DummiesDesigning a Distributed Cloud Database for Dummies
Designing a Distributed Cloud Database for Dummies
 
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
How to Power Innovation with Geo-Distributed Data Management in Hybrid CloudHow to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
How to Power Innovation with Geo-Distributed Data Management in Hybrid Cloud
 
How to Evaluate Cloud Databases for eCommerce
How to Evaluate Cloud Databases for eCommerceHow to Evaluate Cloud Databases for eCommerce
How to Evaluate Cloud Databases for eCommerce
 
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
Webinar: DataStax Enterprise 6: 10 Ways to Multiply the Power of Apache Cassa...
 
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
Webinar: DataStax and Microsoft Azure: Empowering the Right-Now Enterprise wi...
 
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
Webinar - Real-Time Customer Experience for the Right-Now Enterprise featurin...
 
Datastax - The Architect's guide to customer experience (CX)
Datastax - The Architect's guide to customer experience (CX)Datastax - The Architect's guide to customer experience (CX)
Datastax - The Architect's guide to customer experience (CX)
 
An Operational Data Layer is Critical for Transformative Banking Applications
An Operational Data Layer is Critical for Transformative Banking ApplicationsAn Operational Data Layer is Critical for Transformative Banking Applications
An Operational Data Layer is Critical for Transformative Banking Applications
 
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design ThinkingBecoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
Becoming a Customer-Centric Enterprise Via Real-Time Data and Design Thinking
 

Recently uploaded

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

DataStax Enterprise Graph Fundamentals with Real World Example

  • 1. DSE Graph Fundamentals Jon Haddad, DataStax Technical Evangelist @rustyrazorblade
  • 2. © DataStax, All Rights Reserved. A Quick Look at Relational 2
  • 3. © DataStax, All Rights Reserved. Tables • Very structured data • Relational calculus • Various normal forms 3 id name title country 1 jon evangelist usa 2 patrick chief evangelist usa 3 rebecca jr evangelist canada 4 billy ceo usa
  • 4. © DataStax, All Rights Reserved. Selecting and Filtering 4 id name title country 1 jon evangelist usa 2 patrick chief evangelist usa 3 rebecca jr evangelist canada 4 billy ceo usa
  • 5. © DataStax, All Rights Reserved. Selecting and Filtering 4 id name title country 1 jon evangelist usa 2 patrick chief evangelist usa 3 rebecca jr evangelist canada 4 billy ceo usa select * from people where country = 'canada';
  • 6. © DataStax, All Rights Reserved. Selecting and Filtering 4 id name title country 1 jon evangelist usa 2 patrick chief evangelist usa 3 rebecca jr evangelist canada 4 billy ceo usa select * from people where country = 'canada';
  • 7. © DataStax, All Rights Reserved. Foreign Keys 5 id name title country 1 jon evangelist 1 2 patrick chief evangelist 1 3 rebecca jr evangelist 2 4 billy ceo 1 id name 1 usa 2 canada 3 germany 4 japan
  • 8. © DataStax, All Rights Reserved. Foreign Keys 5 id name title country 1 jon evangelist 1 2 patrick chief evangelist 1 3 rebecca jr evangelist 2 4 billy ceo 1 id name 1 usa 2 canada 3 germany 4 japan
  • 9. © DataStax, All Rights Reserved. Foreign Keys 5 id name title country 1 jon evangelist 1 2 patrick chief evangelist 1 3 rebecca jr evangelist 2 4 billy ceo 1 id name 1 usa 2 canada 3 germany 4 japan
  • 10. © DataStax, All Rights Reserved. Joins 6 select * from people join country on people.country = country.id; id name title country name 1 jon evangelist 1 usa 2 patrick chief evangelist 1 usa 3 rebecca jr evangelist 2 canada 4 billy ceo 1 usa
  • 11. © DataStax, All Rights Reserved. Many to Many Relationships 7 id name title 1 jon evangelist 2 patrick chief evangelist 3 rebecca jr evangelist 4 billy ceo id name 1 usa 2 canada 3 germany 4 japan user country 1 1 1 2 2 1 3 2 4 1
  • 12. © DataStax, All Rights Reserved. Many to Many Relationships 7 id name title 1 jon evangelist 2 patrick chief evangelist 3 rebecca jr evangelist 4 billy ceo id name 1 usa 2 canada 3 germany 4 japan user country 1 1 1 2 2 1 3 2 4 1
  • 13. © DataStax, All Rights Reserved. Many to Many Relationships 7 id name title 1 jon evangelist 2 patrick chief evangelist 3 rebecca jr evangelist 4 billy ceo id name 1 usa 2 canada 3 germany 4 japan user country 1 1 1 2 2 1 3 2 4 1
  • 14. © DataStax, All Rights Reserved. Many to Many Relationships 7 id name title 1 jon evangelist 2 patrick chief evangelist 3 rebecca jr evangelist 4 billy ceo id name 1 usa 2 canada 3 germany 4 japan user country 1 1 1 2 2 1 3 2 4 1
  • 15. © DataStax, All Rights Reserved. Many to Many Relationships 7 id name title 1 jon evangelist 2 patrick chief evangelist 3 rebecca jr evangelist 4 billy ceo id name 1 usa 2 canada 3 germany 4 japan user country 1 1 1 2 2 1 3 2 4 1
  • 16. © DataStax, All Rights Reserved. Joining 8 select * from people join people_country on people.id = people_country.user join country on people_country.country = country.id; id name title country name 1 jon evangelist 1 usa 1 jon evangelist 2 canada 2 patrick chief evangelist 1 usa 3 rebecca jr evangelist 2 canada 4 billy ceo 1 usa
  • 17. © DataStax, All Rights Reserved. Joining 8 select * from people join people_country on people.id = people_country.user join country on people_country.country = country.id; id name title country name 1 jon evangelist 1 usa 1 jon evangelist 2 canada 2 patrick chief evangelist 1 usa 3 rebecca jr evangelist 2 canada 4 billy ceo 1 usa
  • 18. © DataStax, All Rights Reserved. A Fun, Real World Example 9
  • 19. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10
  • 20. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 person id name dob
  • 21. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year person id name dob
  • 22. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob
  • 23. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob actor_movie person movie role
  • 24. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob actor_movie person movie role actor_tv person tv_show dob
  • 25. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob actor_movie person movie role actor_tv person tv_show dob
  • 26. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob actor_movie person movie role actor_tv person tv_show dob
  • 27. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob actor_movie person movie role actor_tv person tv_show dob episode tv_show season episode
  • 28. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob actor_movie person movie role actor_tv person tv_show dob episode tv_show season episode actor_episode episode actor
  • 29. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob actor_movie person movie role actor_tv person tv_show dob episode tv_show season episode actor_episode episode actor
  • 30. © DataStax, All Rights Reserved. Media Database 1. People - actors, directories, assistants 2. Movies, TV, episodes 10 movie id name year tv_show id name person id name dob actor_movie person movie role actor_tv person tv_show dob episode tv_show season episode actor_episode episode actor
  • 31. © DataStax, All Rights Reserved. Problems • Every entity gets a table • Lots of many to many tables • Very rigid structure • Going from one to many requires a migration and new data model 11
  • 32. © DataStax, All Rights Reserved. Problems • Every entity gets a table • Lots of many to many tables • Very rigid structure • Going from one to many requires a migration and new data model 11
  • 33. © DataStax, All Rights Reserved. How is this Solved with a Graph? 12
  • 34. © DataStax, All Rights Reserved. Vertex • A vertex represents a "thing" • For example: Movie, Person 13
  • 35. © DataStax, All Rights Reserved. Vertex • A vertex represents a "thing" • For example: Movie, Person 13 JCVD
  • 36. © DataStax, All Rights Reserved. Vertex • A vertex represents a "thing" • For example: Movie, Person 13 JCVD Time cop
  • 37. © DataStax, All Rights Reserved. JCVD Time cop Edge • Edges are labeled relationships • Edges have direction 14
  • 38. © DataStax, All Rights Reserved. JCVD Time cop Edge • Edges are labeled relationships • Edges have direction 14 ActedIn
  • 39. © DataStax, All Rights Reserved. Edges are always many to many 15 JCVD Time cop Blood sport
  • 40. © DataStax, All Rights Reserved. Edges are always many to many 15 JCVD Time copActedIn Blood sport
  • 41. © DataStax, All Rights Reserved. Edges are always many to many 15 JCVD Time copActedIn Blood sport ActedIn
  • 42. © DataStax, All Rights Reserved. Edges are always many to many 15 JCVD Time copActedIn Blood sport ActedIn Directed
  • 43. © DataStax, All Rights Reserved. The power of graph? 16
  • 44. © DataStax, All Rights Reserved. Relationships 17
  • 45. © DataStax, All Rights Reserved. Let's build on that 18
  • 46. © DataStax, All Rights Reserved. Properties • Similar to fields in a table • Much more flexible • Meta properties - properties on properties • Can be on an edge or a vertex • Special property - a label 19 JCVD status amazing charm infinite odds of rendezvous 99.6% enemies decapitated 108747
  • 47. © DataStax, All Rights Reserved. Summary 1. We don't define tables 2. We create vertices to represent real world objects 3. Relationships don't need to be explicitly modeled 4. Expressing complex relationships is not hard 5. Adding new edge types is easy 20
  • 48. © DataStax, All Rights Reserved. Tinkerpop 3 & Gremlin • Cross database graph query framework • API for graph 21
  • 49. © DataStax, All Rights Reserved. TinkerPop Basics 22
  • 50. © DataStax, All Rights Reserved. Create a Vertex 23 graph.createVertex(label, "person", "name", "Jean Claude Van Damme") graph.createVertex(label, "movie", "name", "Bloodsport")
  • 51. © DataStax, All Rights Reserved. Traversals 24 g = graph.traversal() g.V()
  • 52. © DataStax, All Rights Reserved. Finding Vertices 25 g.V().has("person", "name", "Jean Claude van Damme")
  • 53. © DataStax, All Rights Reserved. Finding Vertices 25 g.V().has("person", "name", "Jean Claude van Damme")
  • 54. © DataStax, All Rights Reserved. Finding Vertices 25 g.V().has("person", "name", "Jean Claude van Damme")
  • 55. © DataStax, All Rights Reserved. Finding Vertices 25 g.V().has("person", "name", "Jean Claude van Damme")
  • 56. © DataStax, All Rights Reserved. Finding Vertices 25 g.V().has("person", "name", "Jean Claude van Damme")
  • 57. © DataStax, All Rights Reserved. Create an Edge 26 g.V().has('person', 'name', "Jean Claude Van Damme").as('a'). V().has('movie', 'name', "Bloodsport").as('b'). addE("acted_in").property('year', 1988). from("a").to("b")
  • 58. © DataStax, All Rights Reserved. Traversals 27 jcvd = g.V().has('person','name', "Jean Claude Van Damme")
  • 59. © DataStax, All Rights Reserved. Traversals to neighbors 28 Bloodsport (1988) Kickboxer (1989) Timecop (1994)jcvd.out()
  • 60. © DataStax, All Rights Reserved. Traversals to neighbors 28 Bloodsport (1988) Kickboxer (1989) Timecop (1994)jcvd.out()
  • 61. © DataStax, All Rights Reserved. Traversals to neighbors 28 Bloodsport (1988) Kickboxer (1989) Timecop (1994)jcvd.out()
  • 62. © DataStax, All Rights Reserved. Traversals to edges 29 Bloodsport (1988) Kickboxer (1989) Timecop (1994) jcvd.outE()
  • 63. © DataStax, All Rights Reserved. Traversals to edges 29 Bloodsport (1988) Kickboxer (1989) Timecop (1994) jcvd.outE()
  • 64. © DataStax, All Rights Reserved. Who cares? 30
  • 65. © DataStax, All Rights Reserved. 31 SELECT movie.name from person JOIN roles on person.id = roles.person JOIN movies on roles.movie = movies.id WHERE person.name = "Jean Claude Van Damme"
  • 66. © DataStax, All Rights Reserved. 32 jcvd.out("acted_in")
  • 67. © DataStax, All Rights Reserved. 33
  • 68. © DataStax, All Rights Reserved. 33 NO
  • 69. © DataStax, All Rights Reserved. 34 jcvd.out("acted_in", "directed")
  • 70. © DataStax, All Rights Reserved. 35 SELECT movies.name from person JOIN roles on person.id = roles.person JOIN movies on roles.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN directed on person.id = directed.person JOIN movies on directed.movie = movies.id WHERE actor.name = "Jean Claude Van Damme"
  • 71. © DataStax, All Rights Reserved. SELECT movies.name from person JOIN roles on person.id = roles.person JOIN movies on roles.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN directed on person.id = directed.person JOIN movies on directed.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN produced on person.id = produced.person JOIN movies on produced.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN stage_hand on person.id = stage_hand.person JOIN movies on stage_hand.movie = movies.id
  • 72. © DataStax, All Rights Reserved. SELECT movies.name from person JOIN directed on person.id = directed.person JOIN movies on directed.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN produced on person.id = produced.person JOIN movies on produced.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN stage_hand on person.id = stage_hand.person JOIN movies on stage_hand.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN stage_hand on person.id = stage_hand.person JOIN movies on stage_hand.movie = movies.id WHERE actor.name = "Jean Claude Van Damme"
  • 73. © DataStax, All Rights Reserved. SELECT movies.name from person JOIN directed on person.id = directed.person JOIN movies on directed.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN produced on person.id = produced.person JOIN movies on produced.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN stage_hand on person.id = stage_hand.person JOIN movies on stage_hand.movie = movies.id WHERE actor.name = "Jean Claude Van Damme" UNION SELECT movies.name from person JOIN stage_hand on person.id = stage_hand.person JOIN movies on stage_hand.movie = movies.id WHERE actor.name = "Jean Claude Van Damme"
  • 74. © DataStax, All Rights Reserved. 37 jcvd.out()
  • 75. © DataStax, All Rights Reserved. Who acted with Van Damme and was born in Texas? 38
  • 76. © DataStax, All Rights Reserved. Traversals 39 jcvd.out("acted_in") jcvd acted_in acted_in time cop bloodsport
  • 77. © DataStax, All Rights Reserved. Traversals 39 jcvd.out("acted_in") jcvd acted_in acted_in .in("acted_in") time cop bloodsport
  • 78. © DataStax, All Rights Reserved. Traversals 39 jcvd.out("acted_in") jcvd acted_in acted_in .in("acted_in") ron silveracted_in Bruce McGill acted_in Forest Whitaker acted_in New York Texas Texas time cop bloodsport
  • 79. © DataStax, All Rights Reserved. Traversals 39 jcvd.out("acted_in") jcvd acted_in acted_in .in("acted_in") ron silveracted_in Bruce McGill acted_in Forest Whitaker acted_in New York Texas Texas time cop bloodsport
  • 80. © DataStax, All Rights Reserved. Traversals 39 jcvd.out("acted_in") jcvd acted_in acted_in .has("state_of_birth", "Texas") .in("acted_in") ron silveracted_in Bruce McGill acted_in Forest Whitaker acted_in New York Texas Texas time cop bloodsport
  • 81. © DataStax, All Rights Reserved. Traversals 39 jcvd.out("acted_in") jcvd acted_in acted_in .has("state_of_birth", "Texas") .in("acted_in") ron silveracted_in Bruce McGill acted_in Forest Whitaker acted_in New York Texas Texas time cop bloodsport
  • 82. © DataStax, All Rights Reserved. Creating Indexes 40 schema.vertexLabel('person').index('by_year_born') .materialized().by('year_born').add() schema.vertexLabel('person').index('search'). search().by('biography').asText().add()
  • 83. © DataStax, All Rights Reserved. Creating Indexes 40 schema.vertexLabel('person').index('by_year_born') .materialized().by('year_born').add() schema.vertexLabel('person').index('search'). search().by('biography').asText().add()
  • 84. © DataStax, All Rights Reserved. Creating Indexes 40 schema.vertexLabel('person').index('by_year_born') .materialized().by('year_born').add() schema.vertexLabel('person').index('search'). search().by('biography').asText().add()
  • 85. © DataStax, All Rights Reserved. Who has ANY relationship with any actor born in 1920? 41 g.V().has("person", "year_born", 1920). out("acted_in").in().hasLabel("person")
  • 86. © DataStax, All Rights Reserved. index selection Who has ANY relationship with any actor born in 1920? 41 g.V().has("person", "year_born", 1920). out("acted_in").in().hasLabel("person")
  • 87. © DataStax, All Rights Reserved. Who has ANY relationship with any actor born in 1920? 41 g.V().has("person", "year_born", 1920). out("acted_in").in().hasLabel("person") unconstrained relationships with no foreign keys
  • 88. © DataStax, All Rights Reserved. How do I know Patrick? 42
  • 89. © DataStax, All Rights Reserved. Path Finding! 43
  • 90. © DataStax, All Rights Reserved. 44 jon = g.V().has("nickname", "rustyrazorblade") jon.until(has("nickname", "PatrickMcFadin")). repeat(both())
  • 91. © DataStax, All Rights Reserved. My cousin went to school with Patrick 45 @rustyrazorblade @PatrickMcfadin
  • 92. © DataStax, All Rights Reserved. My cousin went to school with Patrick 45 @rustyrazorblade @PatrickMcfadin cousin @oscar_the_grouch
  • 93. © DataStax, All Rights Reserved. My cousin went to school with Patrick 45 @rustyrazorblade @PatrickMcfadin cousin @oscar_the_grouch attended Cal Poly
  • 94. © DataStax, All Rights Reserved. My cousin went to school with Patrick 45 attended @rustyrazorblade @PatrickMcfadin cousin @oscar_the_grouch attended Cal Poly
  • 95. © DataStax, All Rights Reserved. We have a mutual friend in the same company 46
  • 96. © DataStax, All Rights Reserved. We have a mutual friend in the same company 46 friend
  • 97. © DataStax, All Rights Reserved. We have a mutual friend in the same company 46 friend works_at
  • 98. © DataStax, All Rights Reserved. We have a mutual friend in the same company 46 friend works_at works_at
  • 99. © DataStax, All Rights Reserved. When do you use graph? 47
  • 100. © DataStax, All Rights Reserved. Graph helps solves complex problems by utilizing of the power of relationships 48
  • 101. © DataStax, All Rights Reserved. 49
  • 102. © DataStax, All Rights Reserved. 49 Thank you!!!