SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
© Neo4j, Inc. 2021 CC By-SA 4.0
1
Introduction to Neo4j
Andreas Kollegger
abk@neo4j
Neo4j Graph Academy Live
© Neo4j, Inc. 2021 CC By-SA 4.0
we will answer these questions:
• What is a graph database?
• Why use a graph database?
• How do you query a graph database?
• How is this transformative?
In this session
© Neo4j, Inc. 2021 CC By-SA 4.0
3
What is a graph database?
graph + database = graph database
© Neo4j, Inc. 2021 CC By-SA 4.0
4
A graph is...
a mathematical structure used to model
pairwise relations between objects
Seven Bridges of Konigsberg problem. Leonhard Euler, 1735
© Neo4j, Inc. 2021 CC By-SA 4.0
5
A graph database is...
a database which organizes data using graph structures
a graph
© Neo4j, Inc. 2021 CC By-SA 4.0
Bridges:
1. Krämerbrücke (Trader's Bridge)
2. Schmiedebrücke (Forged Bridge)
3. Holzbrücke (Wood Bridge)
4. Dom Brücke (Cathedral Bridge)
5. Grüne Brücke (Green Bridge)
6. Köttelbrücke (Dung Bridge)
7. Hohe Brücke (High Bridge)
6
A graph database is...
a database which organizes data using graph structures
Districts:
A. Kneiphof (Island, West)
B. Altstadt (North)
C. Lomse (Island, East)
D. Löbenicht (South)
a graph with data
© Neo4j, Inc. 2021 CC By-SA 4.0
Bridges:
1. Krämerbrücke (Trader's Bridge)
cost: 1.0
2. Schmiedebrücke (Forged Bridge)
cost: 1.0
3. Holzbrücke (Wood Bridge)
cost: 1.5
4. Dom Brücke (Cathedral Bridge)
cost: 1.5
5. Grüne Brücke (Green Bridge)
cost: 1.0
6. Köttelbrücke (Dung Bridge)
cost: 1.0
7. Hohe Brücke (High Bridge)
cost:. 4.0
7
A graph database is...
a database which organizes data using graph structures
Land:
A. Kneiphof (Island, Central)
area: 25
B. Altstadt (North)
area: 300
C. Lomse (Island, East)
area: 75
D. Löbenicht (South)
area: 350
© Neo4j, Inc. 2021 CC By-SA 4.0
8
Why use a graph database?
good question
© Neo4j, Inc. 2021 CC By-SA 4.0
9
Use a graph database...
to enjoy Graph benefits
• less friction between how you
think and how the data looks
• user-centric design
• better recommendations
• deeper insights
to solve Graph problems
• model connected data
• faster recursive queries
• path finding
• dependency analysis
9
© Neo4j, Inc. 2021 CC By-SA 4.0
© Neo4j, Inc. 2021 CC By-SA 4.0
Follow the flow - buying sport shoes
© Neo4j, Inc. 2021 CC By-SA 4.0
Panama papers:
simple model,
powerful outcome
© Neo4j, Inc. 2021 CC By-SA 4.0
13
The Panama papers data
model...
© Neo4j, Inc. 2021 CC By-SA 4.0
Roses are red,
facebook is blue,
No mutual friends,
So who are you?
© Neo4j, Inc. 2021 CC By-SA 4.0
...or co-actors of co-actors
Friends of friends
© Neo4j, Inc. 2021 CC By-SA 4.0
What are good graph
scenarios?
© Neo4j, Inc. 2021 CC By-SA 4.0
Scenario 1: Does our problem involve understanding relationships between entities?
Identifying good graph scenarios
● Recommendations
● Fraud detection
● Finding duplicates
● Data lineage
© Neo4j, Inc. 2021 CC By-SA 4.0
Scenario 2: Does the problem involve a lot of self-referencing to the same type of entity?
Identifying good graph scenarios
● Organisational
hierarchies
● Access management
● Social influencers
● Friends of friends
© Neo4j, Inc. 2021 CC By-SA 4.0
Scenario 3: Does the problem explore relationships of varying or unknown depth?
Identifying good graph scenarios
● Supply chain
visibility
● Bill of Materials
● Network
management
© Neo4j, Inc. 2021 CC By-SA 4.0
Scenario 4: Does our problem involve discovering lots of different routes or paths?
Identifying good graph scenarios
● Logistics and routing
● Infrastructure
management
● Dependency tracing
© Neo4j, Inc. 2021 CC By-SA 4.0
21
How do you query a graph
database?
walk like a patternician
© Neo4j, Inc. 2021 CC By-SA 4.0
22
Graph basics...
Node
● The main data element from which graphs are constructed
Jane car
© Neo4j, Inc. 2021 CC By-SA 4.0
23
Graph basics...
23
Node
● The main data element from which graphs are constructed
Relationship
● A link between two nodes. Has:
○ Direction
○ Type
● A node without relationships is permitted. A relationship without nodes is not
Jane car
OWNS
© Neo4j, Inc. 2021 CC By-SA 4.0
24
Graph basics...
Node
Relationship
OWNS
© Neo4j, Inc. 2021 CC By-SA 4.0
25
Graph basics...
Node
Relationship
:Person :Car
OWNS
Label
● Define node category (optional)
© Neo4j, Inc. 2021 CC By-SA 4.0
26
Graph basics...
Node
Relationship
:Person :Car
OWNS
Label
● Define node category (optional)
● Can have more than one
:Asset
© Neo4j, Inc. 2021 CC By-SA 4.0
27
Graph basics...
Node
Relationship
:Person :Car
OWNS
Label
● Define node category (optional)
● Can have more than one
Properties
● Enrich a node or relationship
● Simple key/value pairs!
name: Jane make: Volvo
model: V60
since: 2018
:Asset
© Neo4j, Inc. 2021 CC By-SA 4.0
28
Cypher - the graph query language
A pattern-matching query language made for graphs
© Neo4j, Inc. 2021 CC By-SA 4.0
29
Cypher - the graph query language
A pattern matching query language made for graphs
● Declarative
● Expressive
● Pattern-Matching
© Neo4j, Inc. 2021 CC By-SA 4.0
30
Cypher - the graph query language
30

A pattern matching query language made for graphs
● Declarative
● Expressive
● Pattern Matching
With ASCII ART ¯_(ツ)_/¯
© Neo4j, Inc. 2021 CC By-SA 4.0
Use MATCH to retrieve nodes
//Match all nodes
MATCH (n)
RETURN n;
31
© Neo4j, Inc. 2021 CC By-SA 4.0
Use MATCH to retrieve nodes
//Match all nodes
MATCH (n)
RETURN n;
//Match all nodes with a Person label
MATCH (n:Person)
RETURN n;
32
© Neo4j, Inc. 2021 CC By-SA 4.0
Use MATCH to retrieve nodes
//Match all nodes
MATCH (n)
RETURN n;
//Match all nodes with a Person label
MATCH (n:Person)
RETURN n;
//Match all nodes with a Person label and property name is "Tom Hanks"
MATCH (n:Person {name: "Tom Hanks"})
RETURN n;
33
© Neo4j, Inc. 2021 CC By-SA 4.0
//Return nodes with label Person and name property is "Tom Hanks" - Inline
MATCH (p:Person {name: "Tom Hanks"}) //Only works with exact matches
RETURN p;
Use MATCH and properties to retrieve nodes
34
© Neo4j, Inc. 2021 CC By-SA 4.0
//Return nodes with label Person and name property is "Tom Hanks" - Inline
MATCH (p:Person {name: "Tom Hanks"}) //Only works with exact matches
RETURN p;
//Return nodes with label Person and name property equals "Tom Hanks"
MATCH (p:Person)
WHERE p.name = "Tom Hanks"
RETURN p;
Use MATCH and properties to retrieve nodes
35
© Neo4j, Inc. 2021 CC By-SA 4.0
//Return nodes with label Person and name property is "Tom Hanks" - Inline
MATCH (p:Person {name: "Tom Hanks"}) //Only works with exact matches
RETURN p;
//Return nodes with label Person and name property equals "Tom Hanks"
MATCH (p:Person)
WHERE p.name = "Tom Hanks"
RETURN p;
//Return nodes with label Movie, released property is between 1991 and 1999
MATCH (m:Movie)
WHERE m.released > 1990 AND m.released < 2000
RETURN m;
Use MATCH and properties to retrieve nodes
36
© Neo4j, Inc. 2021 CC By-SA 4.0
Extending the MATCH
37
© Neo4j, Inc. 2021 CC By-SA 4.0
//Find all the movies Tom Hanks acted in
MATCH (:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m:Movie)
RETURN m.title;
Extending the MATCH
38
© Neo4j, Inc. 2021 CC By-SA 4.0
//Find all the movies Tom Hanks acted in
MATCH (:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m:Movie)
RETURN m.title;
//Find all of the co-actors Tom Hanks have worked with
MATCH (:Person {name:"Tom Hanks"})-->(:Movie)<-[:ACTED_IN]-(coActor:Person)
RETURN coActor.name;
Extending the MATCH
39
© Neo4j, Inc. 2021 CC By-SA 4.0
40
How is this transformative?
graph thinking
© Neo4j, Inc. 2021 CC By-SA 4.0
Bridges:
1. Krämerbrücke (Trader's Bridge)
cost: 1.0
2. Schmiedebrücke (Forged Bridge)
cost: 1.0
3. Holzbrücke (Wood Bridge)
cost: 1.5
4. Dom Brücke (Cathedral Bridge)
cost: 1.5
5. Grüne Brücke (Green Bridge)
cost: 1.0
6. Köttelbrücke (Dung Bridge)
cost: 1.0
7. Hohe Brücke (High Bridge)
cost:. 4.0
41
A graph database is...
a database which organizes data using graph structures
Districts:
A. Kneiphof (Island, West)
area: 25
B. Altstadt (North)
area: 300
C. Lomse (Island, East)
area: 75
D. Löbenicht (South)
area: 350
© Neo4j, Inc. 2021 CC By-SA 4.0
42
A graph database is optimized for working with the
connections in data.
All data is connected.
© Neo4j, Inc. 2021 CC By-SA 4.0
All data is connected?
• if you have people, you have relationships
• if you have places, you have roads
• if you have messages, you have replies
• if you have transactions, you have… transactions
• if you have things, you have connections
within those things and to other things
• if you have data, you can always discover or add connections
© Neo4j, Inc. 2021 CC By-SA 4.0
44
If you have connections,
you have new ways
to understand,
to discover,
to enrich
the data you already have.
© Neo4j, Inc. 2021 CC By-SA 4.0
45
Thank you!
Want more! Take this course: Neo4j Overview
https://neo4j.com/graphacademy/training-overview-40/
Next session: Intro to Cypher
Please steal these slides! But give us credit. :)

Más contenido relacionado

Último

Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 

Último (20)

Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 

Introduction to Neo4j by Andreas Kollegger

  • 1. © Neo4j, Inc. 2021 CC By-SA 4.0 1 Introduction to Neo4j Andreas Kollegger abk@neo4j Neo4j Graph Academy Live
  • 2. © Neo4j, Inc. 2021 CC By-SA 4.0 we will answer these questions: • What is a graph database? • Why use a graph database? • How do you query a graph database? • How is this transformative? In this session
  • 3. © Neo4j, Inc. 2021 CC By-SA 4.0 3 What is a graph database? graph + database = graph database
  • 4. © Neo4j, Inc. 2021 CC By-SA 4.0 4 A graph is... a mathematical structure used to model pairwise relations between objects Seven Bridges of Konigsberg problem. Leonhard Euler, 1735
  • 5. © Neo4j, Inc. 2021 CC By-SA 4.0 5 A graph database is... a database which organizes data using graph structures a graph
  • 6. © Neo4j, Inc. 2021 CC By-SA 4.0 Bridges: 1. Krämerbrücke (Trader's Bridge) 2. Schmiedebrücke (Forged Bridge) 3. Holzbrücke (Wood Bridge) 4. Dom Brücke (Cathedral Bridge) 5. Grüne Brücke (Green Bridge) 6. Köttelbrücke (Dung Bridge) 7. Hohe Brücke (High Bridge) 6 A graph database is... a database which organizes data using graph structures Districts: A. Kneiphof (Island, West) B. Altstadt (North) C. Lomse (Island, East) D. Löbenicht (South) a graph with data
  • 7. © Neo4j, Inc. 2021 CC By-SA 4.0 Bridges: 1. Krämerbrücke (Trader's Bridge) cost: 1.0 2. Schmiedebrücke (Forged Bridge) cost: 1.0 3. Holzbrücke (Wood Bridge) cost: 1.5 4. Dom Brücke (Cathedral Bridge) cost: 1.5 5. Grüne Brücke (Green Bridge) cost: 1.0 6. Köttelbrücke (Dung Bridge) cost: 1.0 7. Hohe Brücke (High Bridge) cost:. 4.0 7 A graph database is... a database which organizes data using graph structures Land: A. Kneiphof (Island, Central) area: 25 B. Altstadt (North) area: 300 C. Lomse (Island, East) area: 75 D. Löbenicht (South) area: 350
  • 8. © Neo4j, Inc. 2021 CC By-SA 4.0 8 Why use a graph database? good question
  • 9. © Neo4j, Inc. 2021 CC By-SA 4.0 9 Use a graph database... to enjoy Graph benefits • less friction between how you think and how the data looks • user-centric design • better recommendations • deeper insights to solve Graph problems • model connected data • faster recursive queries • path finding • dependency analysis 9
  • 10. © Neo4j, Inc. 2021 CC By-SA 4.0
  • 11. © Neo4j, Inc. 2021 CC By-SA 4.0 Follow the flow - buying sport shoes
  • 12. © Neo4j, Inc. 2021 CC By-SA 4.0 Panama papers: simple model, powerful outcome
  • 13. © Neo4j, Inc. 2021 CC By-SA 4.0 13 The Panama papers data model...
  • 14. © Neo4j, Inc. 2021 CC By-SA 4.0 Roses are red, facebook is blue, No mutual friends, So who are you?
  • 15. © Neo4j, Inc. 2021 CC By-SA 4.0 ...or co-actors of co-actors Friends of friends
  • 16. © Neo4j, Inc. 2021 CC By-SA 4.0 What are good graph scenarios?
  • 17. © Neo4j, Inc. 2021 CC By-SA 4.0 Scenario 1: Does our problem involve understanding relationships between entities? Identifying good graph scenarios ● Recommendations ● Fraud detection ● Finding duplicates ● Data lineage
  • 18. © Neo4j, Inc. 2021 CC By-SA 4.0 Scenario 2: Does the problem involve a lot of self-referencing to the same type of entity? Identifying good graph scenarios ● Organisational hierarchies ● Access management ● Social influencers ● Friends of friends
  • 19. © Neo4j, Inc. 2021 CC By-SA 4.0 Scenario 3: Does the problem explore relationships of varying or unknown depth? Identifying good graph scenarios ● Supply chain visibility ● Bill of Materials ● Network management
  • 20. © Neo4j, Inc. 2021 CC By-SA 4.0 Scenario 4: Does our problem involve discovering lots of different routes or paths? Identifying good graph scenarios ● Logistics and routing ● Infrastructure management ● Dependency tracing
  • 21. © Neo4j, Inc. 2021 CC By-SA 4.0 21 How do you query a graph database? walk like a patternician
  • 22. © Neo4j, Inc. 2021 CC By-SA 4.0 22 Graph basics... Node ● The main data element from which graphs are constructed Jane car
  • 23. © Neo4j, Inc. 2021 CC By-SA 4.0 23 Graph basics... 23 Node ● The main data element from which graphs are constructed Relationship ● A link between two nodes. Has: ○ Direction ○ Type ● A node without relationships is permitted. A relationship without nodes is not Jane car OWNS
  • 24. © Neo4j, Inc. 2021 CC By-SA 4.0 24 Graph basics... Node Relationship OWNS
  • 25. © Neo4j, Inc. 2021 CC By-SA 4.0 25 Graph basics... Node Relationship :Person :Car OWNS Label ● Define node category (optional)
  • 26. © Neo4j, Inc. 2021 CC By-SA 4.0 26 Graph basics... Node Relationship :Person :Car OWNS Label ● Define node category (optional) ● Can have more than one :Asset
  • 27. © Neo4j, Inc. 2021 CC By-SA 4.0 27 Graph basics... Node Relationship :Person :Car OWNS Label ● Define node category (optional) ● Can have more than one Properties ● Enrich a node or relationship ● Simple key/value pairs! name: Jane make: Volvo model: V60 since: 2018 :Asset
  • 28. © Neo4j, Inc. 2021 CC By-SA 4.0 28 Cypher - the graph query language A pattern-matching query language made for graphs
  • 29. © Neo4j, Inc. 2021 CC By-SA 4.0 29 Cypher - the graph query language A pattern matching query language made for graphs ● Declarative ● Expressive ● Pattern-Matching
  • 30. © Neo4j, Inc. 2021 CC By-SA 4.0 30 Cypher - the graph query language 30  A pattern matching query language made for graphs ● Declarative ● Expressive ● Pattern Matching With ASCII ART ¯_(ツ)_/¯
  • 31. © Neo4j, Inc. 2021 CC By-SA 4.0 Use MATCH to retrieve nodes //Match all nodes MATCH (n) RETURN n; 31
  • 32. © Neo4j, Inc. 2021 CC By-SA 4.0 Use MATCH to retrieve nodes //Match all nodes MATCH (n) RETURN n; //Match all nodes with a Person label MATCH (n:Person) RETURN n; 32
  • 33. © Neo4j, Inc. 2021 CC By-SA 4.0 Use MATCH to retrieve nodes //Match all nodes MATCH (n) RETURN n; //Match all nodes with a Person label MATCH (n:Person) RETURN n; //Match all nodes with a Person label and property name is "Tom Hanks" MATCH (n:Person {name: "Tom Hanks"}) RETURN n; 33
  • 34. © Neo4j, Inc. 2021 CC By-SA 4.0 //Return nodes with label Person and name property is "Tom Hanks" - Inline MATCH (p:Person {name: "Tom Hanks"}) //Only works with exact matches RETURN p; Use MATCH and properties to retrieve nodes 34
  • 35. © Neo4j, Inc. 2021 CC By-SA 4.0 //Return nodes with label Person and name property is "Tom Hanks" - Inline MATCH (p:Person {name: "Tom Hanks"}) //Only works with exact matches RETURN p; //Return nodes with label Person and name property equals "Tom Hanks" MATCH (p:Person) WHERE p.name = "Tom Hanks" RETURN p; Use MATCH and properties to retrieve nodes 35
  • 36. © Neo4j, Inc. 2021 CC By-SA 4.0 //Return nodes with label Person and name property is "Tom Hanks" - Inline MATCH (p:Person {name: "Tom Hanks"}) //Only works with exact matches RETURN p; //Return nodes with label Person and name property equals "Tom Hanks" MATCH (p:Person) WHERE p.name = "Tom Hanks" RETURN p; //Return nodes with label Movie, released property is between 1991 and 1999 MATCH (m:Movie) WHERE m.released > 1990 AND m.released < 2000 RETURN m; Use MATCH and properties to retrieve nodes 36
  • 37. © Neo4j, Inc. 2021 CC By-SA 4.0 Extending the MATCH 37
  • 38. © Neo4j, Inc. 2021 CC By-SA 4.0 //Find all the movies Tom Hanks acted in MATCH (:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m:Movie) RETURN m.title; Extending the MATCH 38
  • 39. © Neo4j, Inc. 2021 CC By-SA 4.0 //Find all the movies Tom Hanks acted in MATCH (:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m:Movie) RETURN m.title; //Find all of the co-actors Tom Hanks have worked with MATCH (:Person {name:"Tom Hanks"})-->(:Movie)<-[:ACTED_IN]-(coActor:Person) RETURN coActor.name; Extending the MATCH 39
  • 40. © Neo4j, Inc. 2021 CC By-SA 4.0 40 How is this transformative? graph thinking
  • 41. © Neo4j, Inc. 2021 CC By-SA 4.0 Bridges: 1. Krämerbrücke (Trader's Bridge) cost: 1.0 2. Schmiedebrücke (Forged Bridge) cost: 1.0 3. Holzbrücke (Wood Bridge) cost: 1.5 4. Dom Brücke (Cathedral Bridge) cost: 1.5 5. Grüne Brücke (Green Bridge) cost: 1.0 6. Köttelbrücke (Dung Bridge) cost: 1.0 7. Hohe Brücke (High Bridge) cost:. 4.0 41 A graph database is... a database which organizes data using graph structures Districts: A. Kneiphof (Island, West) area: 25 B. Altstadt (North) area: 300 C. Lomse (Island, East) area: 75 D. Löbenicht (South) area: 350
  • 42. © Neo4j, Inc. 2021 CC By-SA 4.0 42 A graph database is optimized for working with the connections in data. All data is connected.
  • 43. © Neo4j, Inc. 2021 CC By-SA 4.0 All data is connected? • if you have people, you have relationships • if you have places, you have roads • if you have messages, you have replies • if you have transactions, you have… transactions • if you have things, you have connections within those things and to other things • if you have data, you can always discover or add connections
  • 44. © Neo4j, Inc. 2021 CC By-SA 4.0 44 If you have connections, you have new ways to understand, to discover, to enrich the data you already have.
  • 45. © Neo4j, Inc. 2021 CC By-SA 4.0 45 Thank you! Want more! Take this course: Neo4j Overview https://neo4j.com/graphacademy/training-overview-40/ Next session: Intro to Cypher Please steal these slides! But give us credit. :)