SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
© 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. :)

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Kubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxKubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxPrakarsh -
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxAutus Cyber Tech
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsJaydeep Chhasatia
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?AmeliaSmith90
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntelliSource Technologies
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdfMeon Technology
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilVICTOR MAESTRE RAMIREZ
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesSoftwareMill
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 
About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9Jürgen Gutsch
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfTobias Schneck
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Neo4j
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampVICTOR MAESTRE RAMIREZ
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionsNirav Modi
 

Kürzlich hochgeladen (20)

Kubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptxKubernetes go-live checklist for your microservices.pptx
Kubernetes go-live checklist for your microservices.pptx
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptx
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?
 
Introduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptxIntroduction-to-Software-Development-Outsourcing.pptx
Introduction-to-Software-Development-Outsourcing.pptx
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdf
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-Council
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
Program with GUTs
Program with GUTsProgram with GUTs
Program with GUTs
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retries
 
Sustainable Web Design - Claire Thornewill
Sustainable Web Design - Claire ThornewillSustainable Web Design - Claire Thornewill
Sustainable Web Design - Claire Thornewill
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 
About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9About .NET 8 and a first glimpse into .NET9
About .NET 8 and a first glimpse into .NET9
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in Trivandrum
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - Datacamp
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspections
 

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. :)