SlideShare a Scribd company logo
Application Modeling with Graph
Databases – Relationships are cool!
Lars Martin, JUG Saxony Day, 04.04.2014
Application Modeling with Graph Databases – Relationships are cool!
§  Developer, Architect,
Consultant
§  Java Enterprise, Eclipse,
Continuous …
§  Entrepreneur since 1998
Who’s the guy?
Agenda
² Status Quo
² SQL Join Hell
² Graph Basics
² Application Modeling
Application Modeling with Graph Databases – Relationships are cool!
Application Modeling with Graph Databases – Relationships are cool!
Status Quo
http://db-engines.com/en/ranking_definition
Application Modeling with Graph Databases – Relationships are cool!
SQL Join Hell(1)
Customer
Id Name Address
1Robert 3
2Lars 7
3Michael 23
Address
Id Location
3Berlin
4Munich
7Dresden
23Leipzig
CustomerAddress
CId AId
1 3
2 7
2 8
3 23
Address
Id Location
3Berlin
7Dresden
8New York
23Leipzig
Address
Id Customer Location
3 1Berlin
7 2Dresden
8 2New York
23 3Leipzig
Customer
Id Name
1Robert
2Lars
3Michael
1:1 Relationship
m:n Relationship
1:n Relationship
Customer
Id Name
1Robert
2Lars
3Michael
Application Modeling with Graph Databases – Relationships are cool!
SQL Join Hell(2)
Application Modeling with Graph Databases – Relationships are cool!
SQL Join Hell(3)
­ all JOINs are executed every time you query (traverse)
the relationship
­ executing a JOIN means to search for a key in another
table
­ with Indices executing a JOIN means to lookup a key
­ B-Tree Index: O(log(n))
­ more entries è more lookups è slower JOINs
Application Modeling with Graph Databases - Relationships are cool
Application Modeling with Graph Databases – Relationships are cool!
Graphs – a Crash Course in Coolness
G = (V, E)Graph
Vertex
Edgeh"p://de.wikipedia.org/wiki/Graph_(Graphentheorie)	
  
Application Modeling with Graph Databases – Relationships are cool!
Graphs – a Crash Course in Coolness
Application Modeling with Graph Databases – Relationships are cool!
Graphs – a Crash Course in Coolness
Vertices
•  unique identifier
•  outgoing edges
•  incoming edges
•  key/value pairs
Edges
•  unique identifier
•  start vertex
•  end vertex
•  type
•  key/value pairs
https://github.com/tinkerpop/gremlin/wiki/Defining-a-Property-Graph
index-free adjacency (≈ O(1))
Application Modeling with Graph Databases - Relationships are cool
Application Modeling with Graph Databases – Relationships are cool!
Real World Graphs (1)
maps closely
to the data
model
noun = vertex
verb = edge
Application Modeling with Graph Databases – Relationships are cool!
Real World Graphs (2)
“whiteboard” friendly
Application Modeling with Graph Databases – Relationships are cool!
Ø  Social: Facebook, Twitter, LinkedIn
Ø  Recommendations: Amazon, MovieDB
Ø  Logistics: Package Routing
Ø  Financial: Fraud Detection
Ø  Software: Dependency Management
Ø  Authorization & Access Control:
Ø  …
Real World Graphs (3)
Application Modeling with Graph Databases – Relationships are cool!
Ø  Social: Facebook, Twitter, LinkedIn
Ø  Recommendations: Amazon, MovieDB
Ø  Logistics: Package Routing
Ø  Financial: Fraud Detection
Ø  Software: Dependency Management
Ø  Authorization & Access Control:
Ø  …
Real World Graphs (3)
our area of
activities
Application Modeling with Graph Databases - Relationships are cool
Application Modeling with Graph Databases – Relationships are cool!
Application Modeling
Spring Data – projects.spring.io/spring-data
ü  Spring Data Neo4j supports property graph features
XO - eXtended Objects – github.com/buschmais/xo
ü  Lightweight Datastore-agnostic ORM
ü  Implementation of “Composite Pattern”
ü  Interface based (no POJOS), multiple inheritance
ü  XO-Neo4j supports property graph features
Application Modeling with Graph Databases – Relationships are cool!
Application Modeling
Application Modeling with Graph Databases – Relationships are cool!
Application Modeling
@Label	
public interface User {	
	
@Indexed(unique = true)	
String getName();	
void setName(String name);	
	
@Relation("POSTED")	
@Outgoing	
Set<Tweet> getTweets();	
	
@Relation("FOLLOWS")	
@Outgoing	
Set<User> getFollowing();	
	
}	
@Label	
public interface Tweet {	
	
@Indexed(unique = true)	
long getTweetId();	
void setTweetId(long id);	
	
String getText();	
void setText(String text);	
	
@Relation("POSTED")	
@Incoming	
User getSender();	
void setSender(User sender);	
	
@Relation("MENTIONED")	
@Outgoing	
Set<User> getMentions();	
	…	
}
MATCH	
	(me)-[:POSTED]->(tweet)-[:MENTIONED]->(user)	
WHERE	
	me.name = 'Neo4j’ AND NOT (me)-[:FOLLOWS]->(user)	
WITH	
	user ORDER BY user.name	
RETURN	
	DISTINCT user	
  
Application Modeling with Graph Databases – Relationships are cool!
Application Modeling
@ResultOf	
@Cypher("MATCH (me)-[:POSTED]->(tweet)-
[:MENTIONED]->(user) WHERE id(me) = id({this})
AND NOT (me)-[:FOLLOWS]->(user) WITH user
ORDER BY user.name RETURN DISTINCT user")	
Result<User> suggestFriends();	
  
Demo
Application Modeling with Graph Databases – Relationships are cool!
Application Modeling
Relational Database
•  tabular data structures
Graph Database
•  connected data, esp.
multiple degrees
•  schema-less
Application Modeling with Graph Databases – Relationships are cool!
Application Modeling
“A relational database
may tell you the average
age of everyone in this
place …
… but a graph database
will tell you who is most
likely to buy you a beer.”
Application Modeling with Graph Databases - Relationships are cool
SMB GmbH – Plauenscher Ring 21 – D-01187 Dresden
Dipl.-Inf. Lars Martin
+49-(0)173-64 24 461
lars.martin@smb-tec.com
Application Modeling with Graph Databases - Relationships are cool

More Related Content

KEY
Spring Data Neo4j Intro SpringOne 2011
PDF
The Future is Big Graphs: A Community View on Graph Processing Systems
PDF
An Overview of the Emerging Graph Landscape (Oct 2013)
PPTX
The year of the graph: do you really need a graph database? How do you choose...
PDF
Einführung in Neo4j
PDF
Neanex - Semantic Construction with Graphs
PDF
Bigdata and ai in p2 p industry: Knowledge graph and inference
PDF
Introduction to the graph technologies landscape
Spring Data Neo4j Intro SpringOne 2011
The Future is Big Graphs: A Community View on Graph Processing Systems
An Overview of the Emerging Graph Landscape (Oct 2013)
The year of the graph: do you really need a graph database? How do you choose...
Einführung in Neo4j
Neanex - Semantic Construction with Graphs
Bigdata and ai in p2 p industry: Knowledge graph and inference
Introduction to the graph technologies landscape

What's hot (19)

PPTX
Creating a Data Distribution Knowledge Base using Neo4j, UBS
PDF
Challenges in the Design of a Graph Database Benchmark
PDF
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
PDF
Graph All the Things: An Introduction to Graph Databases
PDF
The Total Economic ImpactTM (TEI) of Neo4j, Featuring Forrester
PDF
GraphConnect SF 2013 Keynote
PDF
Graph Realities
PPTX
The years of the graph: The future of the future is here
PPTX
Towards Automating Data Narratives
PDF
Multiplatform solution for graph datasources
PDF
(Big) Data Science
PDF
Graph based data models
PDF
Unveiling the knowledge in knowledge graphs
PDF
DN18 | From Counting to Connecting: A Networked and Data-Driven Approach to M...
PPTX
Extracting, Aligning, and Linking Data to Build Knowledge Graphs
PPT
Graph db
PDF
Hardcore Data Science - in Practice
PDF
RAPIDS cuGraph – Accelerating all your Graph needs
PDF
Graph visualization options and latest developments
Creating a Data Distribution Knowledge Base using Neo4j, UBS
Challenges in the Design of a Graph Database Benchmark
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graph All the Things: An Introduction to Graph Databases
The Total Economic ImpactTM (TEI) of Neo4j, Featuring Forrester
GraphConnect SF 2013 Keynote
Graph Realities
The years of the graph: The future of the future is here
Towards Automating Data Narratives
Multiplatform solution for graph datasources
(Big) Data Science
Graph based data models
Unveiling the knowledge in knowledge graphs
DN18 | From Counting to Connecting: A Networked and Data-Driven Approach to M...
Extracting, Aligning, and Linking Data to Build Knowledge Graphs
Graph db
Hardcore Data Science - in Practice
RAPIDS cuGraph – Accelerating all your Graph needs
Graph visualization options and latest developments
Ad

Viewers also liked (20)

PDF
Shutl
PDF
Exploring cypher with graph gists
PDF
Graph Databases, a little connected tour (Codemotion Rome)
PDF
Intro to Graphs and Neo4j
PPTX
The Five Graphs of Government: How Federal Agencies can Utilize Graph Technology
PPTX
GraphTalks Rome - Selecting the right Technology
KEY
Intro to Neo4j presentation
PDF
GraphTalks Rome - Introducing Neo4j
PDF
GraphTalks Rome - Identity and Access Management
PDF
GraphTalks Rome - The Italian Business Graph
PPTX
Knowledge Architecture: Graphing Your Knowledge
PDF
Webinar: RDBMS to Graphs
PPTX
IT in Healthcare
PDF
Dear NSA, let me take care of your slides.
PPTX
What I Carry: 10 Tools for Success
PDF
Visualization of Publication Impact
PDF
GraphDay Stockholm - Levaraging Graph-Technology to fight Financial Fraud
PDF
GraphDay Stockholm - Graphs in Action
PDF
GraphDay Stockholm - iKnow Solutions - The Value Add of Graphs to Analytics a...
PDF
GraphDay Stockholm - Telia Zone
Shutl
Exploring cypher with graph gists
Graph Databases, a little connected tour (Codemotion Rome)
Intro to Graphs and Neo4j
The Five Graphs of Government: How Federal Agencies can Utilize Graph Technology
GraphTalks Rome - Selecting the right Technology
Intro to Neo4j presentation
GraphTalks Rome - Introducing Neo4j
GraphTalks Rome - Identity and Access Management
GraphTalks Rome - The Italian Business Graph
Knowledge Architecture: Graphing Your Knowledge
Webinar: RDBMS to Graphs
IT in Healthcare
Dear NSA, let me take care of your slides.
What I Carry: 10 Tools for Success
Visualization of Publication Impact
GraphDay Stockholm - Levaraging Graph-Technology to fight Financial Fraud
GraphDay Stockholm - Graphs in Action
GraphDay Stockholm - iKnow Solutions - The Value Add of Graphs to Analytics a...
GraphDay Stockholm - Telia Zone
Ad

Similar to Application Modeling with Graph Databases - Relationships are cool (20)

PDF
How Graph Databases used in Police Department?
PDF
La bi, l'informatique décisionnelle et les graphes
PDF
Using A Distributed Graph Database To Make Sense Of Disparate Data Stores
PDF
Connecting the Dots—How a Graph Database Enables Discovery
PDF
AI, ML and Graph Algorithms: Real Life Use Cases with Neo4j
PDF
The five graphs of telecommunications may 22 2013 webinar final
PDF
The five graphs of telecommunications may 22 2013 webinar final
PPTX
Sample CS Senior Capstone Projects
PDF
Semantic Security : Authorization on the Web with Ontologies
DOCX
Resume_Vignesh_ThulasiDass
PPTX
Using Connected Data and Graph Technology to Enhance Machine Learning and Art...
PDF
PykQuery.js
PDF
Linked Data Visualization 1st Edition Laura Po
PDF
Pre-Aggregated Analytics And Social Feeds Using MongoDB
PDF
Geschäftliches Potential für System-Integratoren und Berater - Graphdatenban...
PPTX
The Semantic Knowledge Graph
DOCX
TadHenryResume2016
PDF
Linked Data Visualization 1st Edition Laura Po
PDF
Neo4j : la voie du succès avec les bases de données de graphes et la Graph Da...
PPTX
K anonymity for crowdsourcing database
How Graph Databases used in Police Department?
La bi, l'informatique décisionnelle et les graphes
Using A Distributed Graph Database To Make Sense Of Disparate Data Stores
Connecting the Dots—How a Graph Database Enables Discovery
AI, ML and Graph Algorithms: Real Life Use Cases with Neo4j
The five graphs of telecommunications may 22 2013 webinar final
The five graphs of telecommunications may 22 2013 webinar final
Sample CS Senior Capstone Projects
Semantic Security : Authorization on the Web with Ontologies
Resume_Vignesh_ThulasiDass
Using Connected Data and Graph Technology to Enhance Machine Learning and Art...
PykQuery.js
Linked Data Visualization 1st Edition Laura Po
Pre-Aggregated Analytics And Social Feeds Using MongoDB
Geschäftliches Potential für System-Integratoren und Berater - Graphdatenban...
The Semantic Knowledge Graph
TadHenryResume2016
Linked Data Visualization 1st Edition Laura Po
Neo4j : la voie du succès avec les bases de données de graphes et la Graph Da...
K anonymity for crowdsourcing database

More from Lars Martin (7)

PDF
Skalierbares CI Deployment mit Docker
PPTX
Software Development in the Cloud
PDF
Towards Clean Legacy Code
PDF
smart3 - Smart Gardening für smarte Bürger in einer smarten City
PDF
Software Archaeology - Raiders of the Lost Code (long)
PDF
Software Archaeology - Raiders of the Lost Code (short)
KEY
Formal Requirement Engineering with Xtext and ProR
Skalierbares CI Deployment mit Docker
Software Development in the Cloud
Towards Clean Legacy Code
smart3 - Smart Gardening für smarte Bürger in einer smarten City
Software Archaeology - Raiders of the Lost Code (long)
Software Archaeology - Raiders of the Lost Code (short)
Formal Requirement Engineering with Xtext and ProR

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
System and Network Administration Chapter 2
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Transform Your Business with a Software ERP System
PDF
Digital Strategies for Manufacturing Companies
PPT
Introduction Database Management System for Course Database
PPTX
Introduction to Artificial Intelligence
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
L1 - Introduction to python Backend.pptx
PPTX
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
wealthsignaloriginal-com-DS-text-... (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
System and Network Administration Chapter 2
Wondershare Filmora 15 Crack With Activation Key [2025
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Odoo Companies in India – Driving Business Transformation.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Computer Software and OS of computer science of grade 11.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
VVF-Customer-Presentation2025-Ver1.9.pptx
Transform Your Business with a Software ERP System
Digital Strategies for Manufacturing Companies
Introduction Database Management System for Course Database
Introduction to Artificial Intelligence
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
L1 - Introduction to python Backend.pptx
history of c programming in notes for students .pptx

Application Modeling with Graph Databases - Relationships are cool

  • 1. Application Modeling with Graph Databases – Relationships are cool! Lars Martin, JUG Saxony Day, 04.04.2014
  • 2. Application Modeling with Graph Databases – Relationships are cool! §  Developer, Architect, Consultant §  Java Enterprise, Eclipse, Continuous … §  Entrepreneur since 1998 Who’s the guy?
  • 3. Agenda ² Status Quo ² SQL Join Hell ² Graph Basics ² Application Modeling Application Modeling with Graph Databases – Relationships are cool!
  • 4. Application Modeling with Graph Databases – Relationships are cool! Status Quo http://db-engines.com/en/ranking_definition
  • 5. Application Modeling with Graph Databases – Relationships are cool! SQL Join Hell(1) Customer Id Name Address 1Robert 3 2Lars 7 3Michael 23 Address Id Location 3Berlin 4Munich 7Dresden 23Leipzig CustomerAddress CId AId 1 3 2 7 2 8 3 23 Address Id Location 3Berlin 7Dresden 8New York 23Leipzig Address Id Customer Location 3 1Berlin 7 2Dresden 8 2New York 23 3Leipzig Customer Id Name 1Robert 2Lars 3Michael 1:1 Relationship m:n Relationship 1:n Relationship Customer Id Name 1Robert 2Lars 3Michael
  • 6. Application Modeling with Graph Databases – Relationships are cool! SQL Join Hell(2)
  • 7. Application Modeling with Graph Databases – Relationships are cool! SQL Join Hell(3) ­ all JOINs are executed every time you query (traverse) the relationship ­ executing a JOIN means to search for a key in another table ­ with Indices executing a JOIN means to lookup a key ­ B-Tree Index: O(log(n)) ­ more entries è more lookups è slower JOINs
  • 9. Application Modeling with Graph Databases – Relationships are cool! Graphs – a Crash Course in Coolness G = (V, E)Graph Vertex Edgeh"p://de.wikipedia.org/wiki/Graph_(Graphentheorie)  
  • 10. Application Modeling with Graph Databases – Relationships are cool! Graphs – a Crash Course in Coolness
  • 11. Application Modeling with Graph Databases – Relationships are cool! Graphs – a Crash Course in Coolness Vertices •  unique identifier •  outgoing edges •  incoming edges •  key/value pairs Edges •  unique identifier •  start vertex •  end vertex •  type •  key/value pairs https://github.com/tinkerpop/gremlin/wiki/Defining-a-Property-Graph index-free adjacency (≈ O(1))
  • 13. Application Modeling with Graph Databases – Relationships are cool! Real World Graphs (1) maps closely to the data model noun = vertex verb = edge
  • 14. Application Modeling with Graph Databases – Relationships are cool! Real World Graphs (2) “whiteboard” friendly
  • 15. Application Modeling with Graph Databases – Relationships are cool! Ø  Social: Facebook, Twitter, LinkedIn Ø  Recommendations: Amazon, MovieDB Ø  Logistics: Package Routing Ø  Financial: Fraud Detection Ø  Software: Dependency Management Ø  Authorization & Access Control: Ø  … Real World Graphs (3)
  • 16. Application Modeling with Graph Databases – Relationships are cool! Ø  Social: Facebook, Twitter, LinkedIn Ø  Recommendations: Amazon, MovieDB Ø  Logistics: Package Routing Ø  Financial: Fraud Detection Ø  Software: Dependency Management Ø  Authorization & Access Control: Ø  … Real World Graphs (3) our area of activities
  • 18. Application Modeling with Graph Databases – Relationships are cool! Application Modeling Spring Data – projects.spring.io/spring-data ü  Spring Data Neo4j supports property graph features XO - eXtended Objects – github.com/buschmais/xo ü  Lightweight Datastore-agnostic ORM ü  Implementation of “Composite Pattern” ü  Interface based (no POJOS), multiple inheritance ü  XO-Neo4j supports property graph features
  • 19. Application Modeling with Graph Databases – Relationships are cool! Application Modeling
  • 20. Application Modeling with Graph Databases – Relationships are cool! Application Modeling @Label public interface User { @Indexed(unique = true) String getName(); void setName(String name); @Relation("POSTED") @Outgoing Set<Tweet> getTweets(); @Relation("FOLLOWS") @Outgoing Set<User> getFollowing(); } @Label public interface Tweet { @Indexed(unique = true) long getTweetId(); void setTweetId(long id); String getText(); void setText(String text); @Relation("POSTED") @Incoming User getSender(); void setSender(User sender); @Relation("MENTIONED") @Outgoing Set<User> getMentions(); … }
  • 21. MATCH (me)-[:POSTED]->(tweet)-[:MENTIONED]->(user) WHERE me.name = 'Neo4j’ AND NOT (me)-[:FOLLOWS]->(user) WITH user ORDER BY user.name RETURN DISTINCT user   Application Modeling with Graph Databases – Relationships are cool! Application Modeling @ResultOf @Cypher("MATCH (me)-[:POSTED]->(tweet)- [:MENTIONED]->(user) WHERE id(me) = id({this}) AND NOT (me)-[:FOLLOWS]->(user) WITH user ORDER BY user.name RETURN DISTINCT user") Result<User> suggestFriends();  
  • 22. Demo Application Modeling with Graph Databases – Relationships are cool! Application Modeling
  • 23. Relational Database •  tabular data structures Graph Database •  connected data, esp. multiple degrees •  schema-less Application Modeling with Graph Databases – Relationships are cool! Application Modeling “A relational database may tell you the average age of everyone in this place … … but a graph database will tell you who is most likely to buy you a beer.”
  • 25. SMB GmbH – Plauenscher Ring 21 – D-01187 Dresden Dipl.-Inf. Lars Martin +49-(0)173-64 24 461 lars.martin@smb-tec.com