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

PDF
Neo4j Training Modeling
PPTX
Neo4j Training Introduction
PDF
Neo4j Data Science Presentation
PPTX
Visualizing your Graph
PDF
Bootstrapping Recommendations OSCON 2015
PDF
Neo4j Presentation
PDF
Neo4j Training Cypher
PDF
Data modeling with neo4j tutorial
Neo4j Training Modeling
Neo4j Training Introduction
Neo4j Data Science Presentation
Visualizing your Graph
Bootstrapping Recommendations OSCON 2015
Neo4j Presentation
Neo4j Training Cypher
Data modeling with neo4j tutorial

Similar to Data Modeling Tricks for Neo4j (20)

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

More from Max De Marzi (20)

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

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Big Data Technologies - Introduction.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
cuic standard and advanced reporting.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation theory and applications.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
A Presentation on Artificial Intelligence
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Spectral efficient network and resource selection model in 5G networks
Review of recent advances in non-invasive hemoglobin estimation
Big Data Technologies - Introduction.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation_ Review paper, used for researhc scholars
Dropbox Q2 2025 Financial Results & Investor Presentation
Programs and apps: productivity, graphics, security and other tools
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The AUB Centre for AI in Media Proposal.docx
cuic standard and advanced reporting.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Approach and Philosophy of On baking technology
Encapsulation theory and applications.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
20250228 LYD VKU AI Blended-Learning.pptx
NewMind AI Weekly Chronicles - August'25-Week II
A Presentation on Artificial Intelligence

Data Modeling Tricks for Neo4j