SlideShare a Scribd company logo
Graph Data Modeling
Tips and Tricks
github.com/maxdemarzi
About 200 public repositories
Max De Marzi
Neo4j Field Engineer
About
Me !
01
02
03
04
maxdemarzi.com
@maxdemarzi
About 160 blog posts
• Property Graph Data Model
• The most important Slide about Neo4j you will ever see
• Basics of Modeling
• Modeling Acting
• Modeling Flights
• Modeling Twitter
• Modeling Forms
• Modeling Chains
Agenda
Property Graph Model
Property Graph Model Components
Nodes
• Relate nodes by type and direction
• Can have Properties
• Can have Labels
• Can have Properties
name:”Dan”
born: May 29, 1970
twitter:”@dan”
name:”Ann”
born: Dec 5, 1975
Since:
Jan 10, 2011
brand: “Volvo”
model: “V70”
Car
LOVES
LIVES_WITH
D
RIVES
Person
O
W
NS
Relationships
Person
What you (probably) already know:
Data Modeling Tricks for Neo4j
Joins are executed every time
you query the relationship
Executing a Join means to
search for a key
B-Tree Index: O(log(n))
Your data grows by 10x, your time
goes up by one step on each Join
More Data = More Searches
Slower Performance
The Problem
1
2
3
4
Relational Databases can’t handle Relationships
Degraded Performance
Speed plummets as data grows and
as the number of joins grows
Wrong Language
SQL was built with Set Theory in
mind, not Graph Theory
Not Flexible
New types of data and relationships
require schema redesign
Wrong Model
They cannot model or store
relationships without complexity1
2
3
4
NoSQL Databases can’t handle Relationships
Degraded Performance
Speed plummets as you try to join
data together in the application
Wrong Languages
Lots of wacky “almost sql”
languages terrible at “joins”
Not ACID
Eventually Consistent means
Eventually Corrupt
Wrong Model
They cannot model or store
relationships without complexity1
2
3
4
Same Data, Different Layout
No more Tables, no more Foreign Keys, no more Joins
Double Linked List Relationship Layout
Data Modeling Tricks for Neo4j
The Most Important Slide
about Neo4j you will ever see
Fixed Sized Records
“Joins” on Creation
Spin Spin Spin through this
data structure
Pointers instead of Lookups
1
2
3
4
Data Modeling Tricks for Neo4j
Swedes
Partitions
Each Node’s
relationships are
partitioned by
type and direction.
Real-Time Query Performance
Relational and
Other NoSQL
Databases
ResponseTime
Connectedness and Size of Data Set
0 to 2 hops
0 to 3 degrees
Few connections
5+ hops
3+ degrees
Thousands of connections
1000x
Advantage
“Minutes to milliseconds”
Neo4j
I don’t know the average height of all hollywood actors, but I do know the Six Degrees of Kevin Bacon
But not for every query
Reimagine your Data as a Graph
Better Performance
Query relationships in real time
Right Language
Cypher was purpose built for
Graphs
Flexible and Consistent
Evolve your schema seamlessly while
keeping transactions
Right Model
Graphs simplify how you think
1
2
3
4
Agile, High Performance
and Scalable without Sacrifice
Basics of Modeling
Neo4j Property Graph
The Whiteboard Model
is the Physical Model
A unified view for
ultimate agility
• Easily understood
• Easily evolved
• Easy collaboration
between business and IT
http://www.apcjones.com/arrows/#
It’s simple, it’s fast, it doesn’t run out of ink.
Arrows
Nodes can have many relationships
Two Nodes can be related by 

more than one relationship type
Two Nodes can be related by the same
relationship type more than once
Relationships can have properties
Don’t overcomplicate your model
Pick one or the other, not both
…but this is fine:
Modeling Acting
Just draw stuff and “walla” there is your data model
Graphs are Whiteboard Friendly
Movie Property Graph
Some Models are Easy
Data Modeling Tricks for Neo4j
Should Roles be their own Node?
Some Models are Easy but not for all Questions
Modeling Flights
Airports Nodes with Flying To Relationships
How do you model Flight Data?
Maybe Flight should be its own Node?
How do you model Flight Data?
Don’t we care about Flights only on particular Days?
How do you model Flight Data?
What is this trick with the date in the relationship type?
How do you model Flight Data?
We don’t need Airports if we model this way!
How do you model Flight Data?
Lets get Creative
Group Destinations together!
How do you model Flight Data?
OMG WAT!
How do you model Flight Data?
Do not try and bend the data. That’s impossible.
Modeling Twitter
Cloning Twitter
Building a News Feed
9:00 am
@hipster
This is what I had for breakfast! <Insert Image of squirrel food>
8:30 am
@neo4j
Automated tweet telling me about Graph Connect 2020 in NYC on Apr 20-22
8:12 am
@ex-coworker
Stuff I no longer care about.
8:03 am
@someguy
Inspirational Quote of the Day
How do others do it?
Cloning Twitter
The Wrong Way
Modeling a Twitter Feed
A Better Way
Modeling a Twitter Feed
Fixed Sized Records
“Joins” on Creation
Spin Spin Spin through this
data structure
Pointers instead of Lookups
1
2
3
4
Neo4j Secret Sauce Yet Again
Make the Queries Scale
…and the database scales with them.
…and that’s why we don’t make any money.
SCALING OUT
IS IN FASHION
But when your model and your query
match you don’t have to.
Modeling Forms
Fluid Schema
How many arms does the T1000 have in this picture?
No more “Wall Sized” Schema Diagrams
For all forms, all fields, all values you’ll ever need.
Any Form
Wait a minute
• What if they fill out lots of forms?
• What if they respond to the same form twice?
• What if responses to forms are linked together?
• Are we missing a concept?
Responses to Forms
For all forms, all fields, all values you’ll ever need.
Modeling Chains
USE
ISSUES
Terminal ATM-
skimming
Data Breach
Card Holder
Card Issuer
Fraudster
USE $5MAKES
$10
MAKES
$2
MAKES
MAKES $4000
AT
Testing
Merchants
ATMAKES Tx
Tx
$2000
TxTx Tx Tx TxTxTxTx Tx Tx
Computer
Store
John
Tx
$2000
TxTx Tx Tx TxTxTxTx Tx Tx
Computer
Store
John
Tx
$2000
TxTx Tx Tx TxTxTxTx Tx Tx
Computer
Store
John
Data Modeling Tricks for Neo4j
TxTx
$2
TxTx
Tx
$2000
Tx Tx
$25$10$4
TxTx Tx Tx TxTxTx
Computer
Store
John
Gas Station
Sheila
Robert
$3
Karen
TxTxTx Tx Tx TxTx
$3000
Tx
Jewelry
StoreTx
$3
TxTxTx Tx Tx TxTx TxTx
TxTx TxTx Tx Tx TxTx
$8 $12
Tx
$1500
Furniture
Store
Tx Tx Tx
Hunger Games
1. What is the Tool Max uses for Modeling?
2. Up to how many relationship types can I use?
A. 8192
B. 32768
C. 65536
3. What is the secret to Neo4j?
Questions
Thank you!

More Related Content

Similar to Data Modeling Tricks for Neo4j (20)

PDF
Thinking about graphs
Neo4j
 
PDF
Introduction to Graph databases and Neo4j (by Stefan Armbruster)
barcelonajug
 
PPTX
Graph Data Modeling Best Practices(Eric_Monk).pptx
Neo4j
 
PPTX
Introduction to graph databases in term of neo4j
Abdullah Hamidi
 
PDF
Intro to Neo4j and Graph Databases
Neo4j
 
PDF
Neo4j in Depth
Max De Marzi
 
PDF
Training Series - Intro to Neo4j
Neo4j
 
PDF
5.17 - IntroductionToNeo4j-allSlides_1_2022_DanMc.pdf
javiertec21
 
PPTX
Introduction: Relational to Graphs
Neo4j
 
PDF
Workshop Introduction to Neo4j
Neo4j
 
PDF
Getting started with Graph Databases & Neo4j
Suroor Wijdan
 
PPTX
Intro to Neo4j with Ruby
Max De Marzi
 
PPTX
Chalter 1. Neo4j.pptx
mbabaqi2020
 
PDF
Training Week: Introduction to Neo4j 2022
Neo4j
 
PDF
managing big data
Suveeksha
 
PDF
GraphSummit Toronto: Keynote - Innovating with Graphs
Neo4j
 
PDF
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
Neo4j
 
PDF
Introducing Neo4j
Neo4j
 
PDF
Introduction to Graphs with Neo4j
Neo4j
 
PPTX
A whirlwind tour of graph databases
jexp
 
Thinking about graphs
Neo4j
 
Introduction to Graph databases and Neo4j (by Stefan Armbruster)
barcelonajug
 
Graph Data Modeling Best Practices(Eric_Monk).pptx
Neo4j
 
Introduction to graph databases in term of neo4j
Abdullah Hamidi
 
Intro to Neo4j and Graph Databases
Neo4j
 
Neo4j in Depth
Max De Marzi
 
Training Series - Intro to Neo4j
Neo4j
 
5.17 - IntroductionToNeo4j-allSlides_1_2022_DanMc.pdf
javiertec21
 
Introduction: Relational to Graphs
Neo4j
 
Workshop Introduction to Neo4j
Neo4j
 
Getting started with Graph Databases & Neo4j
Suroor Wijdan
 
Intro to Neo4j with Ruby
Max De Marzi
 
Chalter 1. Neo4j.pptx
mbabaqi2020
 
Training Week: Introduction to Neo4j 2022
Neo4j
 
managing big data
Suveeksha
 
GraphSummit Toronto: Keynote - Innovating with Graphs
Neo4j
 
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
Neo4j
 
Introducing Neo4j
Neo4j
 
Introduction to Graphs with Neo4j
Neo4j
 
A whirlwind tour of graph databases
jexp
 

More from Max De Marzi (20)

PDF
AI, Tariffs and Supply Chains in Knowledge Graphs
Max De Marzi
 
PDF
DataDay 2023 Presentation
Max De Marzi
 
PDF
DataDay 2023 Presentation - Notes
Max De Marzi
 
PPTX
Developer Intro Deck-PowerPoint - Download for Speaker Notes
Max De Marzi
 
PDF
Outrageous Ideas for Graph Databases
Max De Marzi
 
PDF
Detenga el fraude complejo con Neo4j
Max De Marzi
 
PDF
Fraud Detection and Neo4j
Max De Marzi
 
PDF
Detecion de Fraude con Neo4j
Max De Marzi
 
PDF
Neo4j Stored Procedure Training Part 2
Max De Marzi
 
PDF
Neo4j Stored Procedure Training Part 1
Max De Marzi
 
PDF
Decision Trees in Neo4j
Max De Marzi
 
PDF
Neo4j y Fraude Spanish
Max De Marzi
 
PDF
Neo4j Fundamentals
Max De Marzi
 
PDF
Fraud Detection Class Slides
Max De Marzi
 
PDF
What Finance can learn from Dating Sites
Max De Marzi
 
PDF
Bootstrapping Recommendations with Neo4j
Max De Marzi
 
PDF
Data 2.0
Max De Marzi
 
PDF
Graph database Use Cases
Max De Marzi
 
PPTX
Windy City DB - Recommendation Engine with Neo4j
Max De Marzi
 
PPT
Intro to Mutating Cypher
Max De Marzi
 
AI, Tariffs and Supply Chains in Knowledge Graphs
Max De Marzi
 
DataDay 2023 Presentation
Max De Marzi
 
DataDay 2023 Presentation - Notes
Max De Marzi
 
Developer Intro Deck-PowerPoint - Download for Speaker Notes
Max De Marzi
 
Outrageous Ideas for Graph Databases
Max De Marzi
 
Detenga el fraude complejo con Neo4j
Max De Marzi
 
Fraud Detection and Neo4j
Max De Marzi
 
Detecion de Fraude con Neo4j
Max De Marzi
 
Neo4j Stored Procedure Training Part 2
Max De Marzi
 
Neo4j Stored Procedure Training Part 1
Max De Marzi
 
Decision Trees in Neo4j
Max De Marzi
 
Neo4j y Fraude Spanish
Max De Marzi
 
Neo4j Fundamentals
Max De Marzi
 
Fraud Detection Class Slides
Max De Marzi
 
What Finance can learn from Dating Sites
Max De Marzi
 
Bootstrapping Recommendations with Neo4j
Max De Marzi
 
Data 2.0
Max De Marzi
 
Graph database Use Cases
Max De Marzi
 
Windy City DB - Recommendation Engine with Neo4j
Max De Marzi
 
Intro to Mutating Cypher
Max De Marzi
 
Ad

Recently uploaded (20)

PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Designing Production-Ready AI Agents
Kunal Rai
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
July Patch Tuesday
Ivanti
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Biography of Daniel Podor.pdf
Daniel Podor
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Ad

Data Modeling Tricks for Neo4j