SlideShare a Scribd company logo
1 of 49
Save your relation
with a Graph
Graph databases in .NET
Daniël te Winkel
d.te.winkel@betabit.nl
@daniel_tewinkel #syrwag
Agenda
• Introduction
• Use cases
• Tools and first code
break
• Modelling
• Graph languages
• CRUD
• Querying
Agenda Break
Includes
Introduction
Graph theory
First paper by Leonhard Euler (1707-1783)
Seven Bridges of Königsberg, published in 1736
Seven Bridges of Königsberg
Devise a walk through the city that would cross each of those
bridges once and only once.
Vertices and Edges
Or nodes and relationships…
Or nodes and edges…
Vertex
Edge
Directed Property Graph
Nodes and relationships can have labels.
Nodes and relationships can have properties.
Graphs are schemaless (NoSQL)
Person
Name: Jan
Age: 55
Person
Name: Alex
Age: 35
Role: Tester
MANAGES
Since: 2017-05-12
It’s all about the paths
A path is a sequence of nodes connected by relations.
John BobAlice Charly
FRIEND_OFFRIEND_OF FRIEND_OF
Graph databases
• Cosmos DB (Tinkerpop)
• Neo4j
• TinkerPop
• Microsoft SQL server 2017
• AllegroGraph
• OrientDB
• Many more…
Graph languages
• Gremlin (Cosmos DB / Tinkerpop)
• Cypher (Neo4j)
• GraphQL
• SPARQL (Allegrograph)
• A few more…
Cosmos DB / Gremlin
Microsoft’s multi-model database in Azure
• Globally distributed
• Massive scale
• Guaranteed low latency
• Very high availablity
• Five consistency levels
• Graph model based on Tinkerpop
• RUs / second (~ read of 1KB document)
Cosmos DB - Partitioning
• Partition key optional if collection < 10GB
• Ids for Vertices and Edges must be unique per partition
• Partition key property must be present in each vertex
• Edges are stored in same partition as their out vertex
• john.addE('knows').to(mary)
• PartitionKey property?
• Choose partition key to best query from a single partition?
Cosmos DB - Partitioning
Neo4j / Cypher
• (One of) the oldest players in the field
• Native graph storage and processing
• Huge community
• Easy to learn
• Free (e-)book 
• Enterprise grade graph database
• Java, C#, Python, Javascript, Ruby, and more
What about the competition?
Why not use SQL?
• Joining tables for relation can become slow and
cumbersome.
Or another NoSQL solution?
• In general, they don’t support relations at all.
They may or may not be a better option for some use cases but
not for…
Use Cases
Use cases for Graph databases
• Social data
• Recommendations
• Fraud detection
• Geospatial
• Authorization
• Analytics
Social data
Common friends
Influencers
Six degrees of separation?
John
Bob
Alice
Charly
FRIEND_OF
FRIEND_OF
FRIEND_OF
FRIEND_OF
KNOWS?
Geospacial
Eulers problem
Route calculations
• Shortest
• Cheapest
10
A
3
2
2
1
5
B
D
C
15
Sales
Authorization
Store and verify fine-grained access control
John
Sales
Manage-
ment
Sales
documen
ts
DENIED
ALLOWED
Manage-
mentINHERITS_FROM
Tools and first code
Cosmos DB
Azure Portal
Neo4j
Desktop
Browser
Apache Tinkerpop
Run as local Server
• Not the same as Cosmos DB!
Run local client
• Tekst based
• Can connect to Cosmos DB
Visual Studio Code
Useful plugins:
• Cypher Query Language
• Azure Cosmos DB
Tools demo
And a bit of
(query) code
Code demo – Connecting to the
database
Break
(Daniël)-[Needs]->(Coffee)
Some magic?
T RI M P
Modelling
Start with a whiteboard!
• Graphs are natural to draw; just circles and arrows.
• Use real examples
• Don’t try to put too much detail in
Test in a database
Enter the examples in a database.
Test with queries that the business requires.
john = g.addV('Person').property('name', 'John')
mary = g.addV('Person').property('name', 'Mary')
john.addE('MAILED').to(mary)
Step by step
Next increment:
• On whiteboard
• In database
• Test queries
What is what
Nodes should describe things
Relations should describe the relation between the things
John Mary
FOLLOWS
Labels or properties
Using specialised relationships will be faster to query
Sales
Sales
docs
DENIED
Sales
Sales
docs
PERMISSION
{type: denied}
Graph languages
Gremlin
• Developed by Apache
• Functional language
• Multiple values possible for a Vertex property
• Many Dialects
• Gremlin-Java8, Gremlin-Groovy, Gremlin-Python, e.t.c.
Cypher
• Created by Neo4j
• Open sourced as openCypher
• Graph query language
• Declarative pattern matching
• Similarities to SQL
(Neo4j)-[created]->(Cypher)
My first query
Return all vertices.
Cypher: match (n) return n
Gremlin: g.V()
Return all vertices with a given name.
Cypher: match (n {name: “john”}) return n
Gremlin: g.V().has(‘name’, ‘john’)
CRUD
CRUD
• Some Gremlin
• A bit more Cypher
• And some C#
Querying
Querying
(Daniël)-[Shows]->(Some queries)
10
A
3
2
2
1
5
B
D
C
15
The end?
Hands-on session?
If you are interested in a hands-on session to explore the
(IMDB?) Graph database technology, please respond to the
feedback mail
Questions?
Conclusions
Graph databases are great at querying connected data.
Graph databases are a great tool to have in your data toolbox!
More information
Links to the presentation and the code will be shared at:
https://www.betabit.nl/nl/kennis/save-your-relation-with-a-
graph
Thank you for your time
and attention

More Related Content

Similar to Betabit - syrwag 2018-03-28

Intro to Graphs for Fedict
Intro to Graphs for FedictIntro to Graphs for Fedict
Intro to Graphs for FedictRik Van Bruggen
 
NOSQL Databases for the .NET Developer
NOSQL Databases for the .NET DeveloperNOSQL Databases for the .NET Developer
NOSQL Databases for the .NET DeveloperJesus Rodriguez
 
Introduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jIntroduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jAbdullah Hamidi
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQLYan Cui
 
Neo4j Presentation
Neo4j PresentationNeo4j Presentation
Neo4j PresentationMax De Marzi
 
Thinking about graphs
Thinking about graphsThinking about graphs
Thinking about graphsNeo4j
 
FP Days: Down the Clojure Rabbit Hole
FP Days: Down the Clojure Rabbit HoleFP Days: Down the Clojure Rabbit Hole
FP Days: Down the Clojure Rabbit HoleChristophe Grand
 
Introduction to Neo4j for the Emirates & Bahrain
Introduction to Neo4j for the Emirates & BahrainIntroduction to Neo4j for the Emirates & Bahrain
Introduction to Neo4j for the Emirates & BahrainNeo4j
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015Himanshu Desai
 
Graph Databases & OrientDB
Graph Databases & OrientDBGraph Databases & OrientDB
Graph Databases & OrientDBArpit Poladia
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jCorie Pollock
 
Intro to Neo4j with Ruby
Intro to Neo4j with RubyIntro to Neo4j with Ruby
Intro to Neo4j with RubyMax De Marzi
 
Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklNeo4j
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsKorea Sdec
 
Gephi, Graphx, and Giraph
Gephi, Graphx, and GiraphGephi, Graphx, and Giraph
Gephi, Graphx, and GiraphDoug Needham
 
Graphs fun vjug2
Graphs fun vjug2Graphs fun vjug2
Graphs fun vjug2Neo4j
 

Similar to Betabit - syrwag 2018-03-28 (20)

Intro to Graphs for Fedict
Intro to Graphs for FedictIntro to Graphs for Fedict
Intro to Graphs for Fedict
 
NOSQL Databases for the .NET Developer
NOSQL Databases for the .NET DeveloperNOSQL Databases for the .NET Developer
NOSQL Databases for the .NET Developer
 
Introduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jIntroduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4j
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Neo4j Presentation
Neo4j PresentationNeo4j Presentation
Neo4j Presentation
 
Thinking about graphs
Thinking about graphsThinking about graphs
Thinking about graphs
 
FP Days: Down the Clojure Rabbit Hole
FP Days: Down the Clojure Rabbit HoleFP Days: Down the Clojure Rabbit Hole
FP Days: Down the Clojure Rabbit Hole
 
Graph of Thrones - Neo4j + Game of Thrones
Graph of Thrones - Neo4j + Game of Thrones Graph of Thrones - Neo4j + Game of Thrones
Graph of Thrones - Neo4j + Game of Thrones
 
Introduction to Neo4j for the Emirates & Bahrain
Introduction to Neo4j for the Emirates & BahrainIntroduction to Neo4j for the Emirates & Bahrain
Introduction to Neo4j for the Emirates & Bahrain
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015
 
NoSQL, which way to go?
NoSQL, which way to go?NoSQL, which way to go?
NoSQL, which way to go?
 
Graph Databases & OrientDB
Graph Databases & OrientDBGraph Databases & OrientDB
Graph Databases & OrientDB
 
Polyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4jPolyglot Persistence with MongoDB and Neo4j
Polyglot Persistence with MongoDB and Neo4j
 
Intro to Neo4j with Ruby
Intro to Neo4j with RubyIntro to Neo4j with Ruby
Intro to Neo4j with Ruby
 
Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quickl
 
How to choose a database
How to choose a databaseHow to choose a database
How to choose a database
 
Graph Databases
Graph DatabasesGraph Databases
Graph Databases
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and models
 
Gephi, Graphx, and Giraph
Gephi, Graphx, and GiraphGephi, Graphx, and Giraph
Gephi, Graphx, and Giraph
 
Graphs fun vjug2
Graphs fun vjug2Graphs fun vjug2
Graphs fun vjug2
 

Recently uploaded

Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
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
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
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
 
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
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...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
 
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
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
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
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
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
 

Recently uploaded (20)

Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
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 ...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.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
 
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
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
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
 
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
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
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 ?
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
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
 

Betabit - syrwag 2018-03-28

  • 1. Save your relation with a Graph Graph databases in .NET Daniël te Winkel d.te.winkel@betabit.nl @daniel_tewinkel #syrwag
  • 2. Agenda • Introduction • Use cases • Tools and first code break • Modelling • Graph languages • CRUD • Querying Agenda Break Includes
  • 4. Graph theory First paper by Leonhard Euler (1707-1783) Seven Bridges of Königsberg, published in 1736
  • 5. Seven Bridges of Königsberg Devise a walk through the city that would cross each of those bridges once and only once.
  • 6. Vertices and Edges Or nodes and relationships… Or nodes and edges… Vertex Edge
  • 7. Directed Property Graph Nodes and relationships can have labels. Nodes and relationships can have properties. Graphs are schemaless (NoSQL) Person Name: Jan Age: 55 Person Name: Alex Age: 35 Role: Tester MANAGES Since: 2017-05-12
  • 8. It’s all about the paths A path is a sequence of nodes connected by relations. John BobAlice Charly FRIEND_OFFRIEND_OF FRIEND_OF
  • 9. Graph databases • Cosmos DB (Tinkerpop) • Neo4j • TinkerPop • Microsoft SQL server 2017 • AllegroGraph • OrientDB • Many more…
  • 10. Graph languages • Gremlin (Cosmos DB / Tinkerpop) • Cypher (Neo4j) • GraphQL • SPARQL (Allegrograph) • A few more…
  • 11. Cosmos DB / Gremlin Microsoft’s multi-model database in Azure • Globally distributed • Massive scale • Guaranteed low latency • Very high availablity • Five consistency levels • Graph model based on Tinkerpop • RUs / second (~ read of 1KB document)
  • 12. Cosmos DB - Partitioning • Partition key optional if collection < 10GB • Ids for Vertices and Edges must be unique per partition • Partition key property must be present in each vertex • Edges are stored in same partition as their out vertex • john.addE('knows').to(mary) • PartitionKey property? • Choose partition key to best query from a single partition?
  • 13. Cosmos DB - Partitioning
  • 14. Neo4j / Cypher • (One of) the oldest players in the field • Native graph storage and processing • Huge community • Easy to learn • Free (e-)book  • Enterprise grade graph database • Java, C#, Python, Javascript, Ruby, and more
  • 15. What about the competition? Why not use SQL? • Joining tables for relation can become slow and cumbersome. Or another NoSQL solution? • In general, they don’t support relations at all. They may or may not be a better option for some use cases but not for…
  • 17. Use cases for Graph databases • Social data • Recommendations • Fraud detection • Geospatial • Authorization • Analytics
  • 18. Social data Common friends Influencers Six degrees of separation? John Bob Alice Charly FRIEND_OF FRIEND_OF FRIEND_OF FRIEND_OF KNOWS?
  • 19. Geospacial Eulers problem Route calculations • Shortest • Cheapest 10 A 3 2 2 1 5 B D C 15
  • 20. Sales Authorization Store and verify fine-grained access control John Sales Manage- ment Sales documen ts DENIED ALLOWED Manage- mentINHERITS_FROM
  • 24. Apache Tinkerpop Run as local Server • Not the same as Cosmos DB! Run local client • Tekst based • Can connect to Cosmos DB
  • 25. Visual Studio Code Useful plugins: • Cypher Query Language • Azure Cosmos DB
  • 26. Tools demo And a bit of (query) code
  • 27. Code demo – Connecting to the database
  • 31. Start with a whiteboard! • Graphs are natural to draw; just circles and arrows. • Use real examples • Don’t try to put too much detail in
  • 32. Test in a database Enter the examples in a database. Test with queries that the business requires. john = g.addV('Person').property('name', 'John') mary = g.addV('Person').property('name', 'Mary') john.addE('MAILED').to(mary)
  • 33. Step by step Next increment: • On whiteboard • In database • Test queries
  • 34. What is what Nodes should describe things Relations should describe the relation between the things John Mary FOLLOWS
  • 35. Labels or properties Using specialised relationships will be faster to query Sales Sales docs DENIED Sales Sales docs PERMISSION {type: denied}
  • 37. Gremlin • Developed by Apache • Functional language • Multiple values possible for a Vertex property • Many Dialects • Gremlin-Java8, Gremlin-Groovy, Gremlin-Python, e.t.c.
  • 38. Cypher • Created by Neo4j • Open sourced as openCypher • Graph query language • Declarative pattern matching • Similarities to SQL (Neo4j)-[created]->(Cypher)
  • 39. My first query Return all vertices. Cypher: match (n) return n Gremlin: g.V() Return all vertices with a given name. Cypher: match (n {name: “john”}) return n Gremlin: g.V().has(‘name’, ‘john’)
  • 40. CRUD
  • 41. CRUD • Some Gremlin • A bit more Cypher • And some C#
  • 45. Hands-on session? If you are interested in a hands-on session to explore the (IMDB?) Graph database technology, please respond to the feedback mail
  • 47. Conclusions Graph databases are great at querying connected data. Graph databases are a great tool to have in your data toolbox!
  • 48. More information Links to the presentation and the code will be shared at: https://www.betabit.nl/nl/kennis/save-your-relation-with-a- graph
  • 49. Thank you for your time and attention

Editor's Notes

  1. https://en.wikipedia.org/wiki/Graph_theory Euler: Swiss mathematician, physicist, astronomer, logician and engineer
  2. The city of Königsberg in Prussia (now Kaliningrad, Russia)
  3. https://en.wikipedia.org/wiki/Vertex_(graph_theory) The names used depend on the used graph database.
  4. Property graph is the most popular type of graph. Other types are triples (RDF (Resource Description Framework)) and hypergraphs. Properties are key-value pairs. In Tinkerpop Vertex properties can have multiple values! Labels act as a type identifier.
  5. In graph theory, a path in a graph is a finite or infinite sequence of edges which connect a sequence of vertices which, by most definitions, are all distinct from one another. In a directed graph, a directed path is again a sequence of edges which connect a sequence of vertices, but with the added restriction that the edges all be directed in the same direction.
  6. Allegrograph is a RDF (Resource Description Framework) database.
  7. Gremlin Cypher, openCypher GraphQL – Developed by Facebook.
  8. The core type system of Azure Cosmos DB’s database engine is atom-record-sequence (ARS) based. Atoms consist of a small set of primitive types e.g. string, bool, number etc., records are structs and sequences are arrays consisting of atoms, records or sequences. Cosmos DB also support Table, Document Partitioning is important for massive scale.
  9. https://azure.microsoft.com/en-us/blog/10-things-to-know-about-documentdb-partitioned-collections/ Without partition key CRUD by ID With partition key CRUD by partition Key + ID
  10. https://azure.microsoft.com/en-us/blog/10-things-to-know-about-documentdb-partitioned-collections/ Without partition key CRUD by ID With partition key CRUD by partition Key + ID
  11. Neo4j does support Gremlin, but promotes Cypher over Gremlin.
  12. Facebook Linked-in Facebook calculated degree of seperation is 3.5 (4 Feb 2016. https://research.fb.com/three-and-a-half-degrees-of-separation/)
  13. Create with
  14. Thanks to Victor Mids / MindF*ck
  15. Details will come later
  16. Properties of a realtion should describe the reation, not things. E-mail example.