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
Ā 
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 Jhonathan de Souza Soares
Ā 
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
Ā 
NoSQL, which way to go?
NoSQL, which way to go?NoSQL, which way to go?
NoSQL, which way to go?Ahmed Elharouny
Ā 
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
Ā 
How to choose a database
How to choose a databaseHow to choose a database
How to choose a databaseVsevolod Solovyov
Ā 
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

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
Ā 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
Ā 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
Ā 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
Ā 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
Ā 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
Ā 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
Ā 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
Ā 
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfGOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfAlina Yurenko
Ā 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
Ā 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
Ā 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
Ā 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
Ā 
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·åŠžē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·umasea
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
Ā 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
Ā 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
Ā 

Recently uploaded (20)

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
Ā 
Call Girls In Mukherjee Nagar šŸ“± 9999965857 šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Call Girls In Mukherjee Nagar šŸ“±  9999965857  šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...Call Girls In Mukherjee Nagar šŸ“±  9999965857  šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Call Girls In Mukherjee Nagar šŸ“± 9999965857 šŸ¤© Delhi šŸ«¦ HOT AND SEXY VVIP šŸŽ SE...
Ā 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
Ā 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Ā 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
Ā 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
Ā 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
Ā 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
Ā 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
Ā 
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfGOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
Ā 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
Ā 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
Ā 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
Ā 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Ā 
Hot Sexy call girls in Patel NagaršŸ” 9953056974 šŸ” escort Service
Hot Sexy call girls in Patel NagaršŸ” 9953056974 šŸ” escort ServiceHot Sexy call girls in Patel NagaršŸ” 9953056974 šŸ” escort Service
Hot Sexy call girls in Patel NagaršŸ” 9953056974 šŸ” escort Service
Ā 
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·åŠžē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Ā 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Ā 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
Ā 

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.