SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
Surrounded by Graphs
a short introduction to Graph Databases
and Neo4j
Created by , Neo Technology Inc.Julian Simpson
@builddoctor
Introduction: Who are you?
Yes, you!
0
Introduction: Who am I?
Dotbomb Solaris Admin
Reformed Java Build Monkey
DevOps Agitator
(Who actually went to DevOpsDays conference #1)
Full Stack Developer at Neo Technology, makers of Neo4j
Agenda: What's this talk about?
NoSQL Landscape
What are graphs, really?
Graph Examples
Neo4j Example and Story Time
Questions
Define NoSQL
(from: http://martinfowler.com/bliki/NosqlDe nition.html)
Not using the relational model (nor the SQL language)
Open source (mostly)
Designed to run on large clusters (mostly)
Based on the needs of 21st century web properties
No schema, allowing elds to be added to any record without controls
4 kinds of NoSQL Database
Key-Value (e.g. BerkeleyDB, Redis)
Document (e.g. MongoDB, CouchDB)
Column Family (e.g. Cassandra, Vertica)
Graph (e.g. Neo4j, In niteGraph)
Most content stolen from NoSQL Distilled: A Brief Guide to the Emerging
World of Polyglot Persistence Paperback – August 18, 2012 by Pramod J.
Sadalage, Martin Fowler
Key Value
Definition
A simple hash table, primarily used when all access to
the database is via primary key
Example
<SEThobbit:name"baggins"
OK
<GEThobbit:name
"baggins"
Key Value
Use Cases
Recommended Not Recommended
Storing Session Information Relationships among data
User Pro les and Preferences Multi Operation Transactions
Shopping Cart Data Operations by Sets
Query by Data
Document Database
Definition
... documents are self-describing, hierarchical tree
data structures which can consist of maps, collections
and scalar values.
Example
{
"_id":1,
"name":{
"first":"Bilbo",
"last":"Baggins"
},
"comment":"Aren'twegladthishobbitbusinessisdone?"
}
Document Database
Use Cases
Recommended Not Recommended
Event Logging Complex Transactions spanning di erent
documents
Blogging, CMS
platforms
Queries against varying aggregate structure
Web or Real-Time
analytics
E-Commerce
Column Family Stores
Definition
... store data with keys mapped to values and the
values grouped into multiple column families, each
column family being a map of data
Example
{
"bilbo":{
age:"eleventysix",
surname:"baggins"
},
"frodo":{
nickname:"Mr.Frodo",
surname:"Baggins"
}
Column Family Stores
Use Cases
Recommended Not Recommended
Event Logging ACID Transactions
Content Management Systems, Blogging
platforms
Early Prototypes and
Spikes
Counters
Expiring Usage
Graph Databases
Definition
... store entities and relationships between those
entities.
Example
create(bilbo:Hobbit{name:'BilboBaggins'});
create(frodo:Hobbit{name:'FrodoBaggins'});
create(bilbo)-[:UNCLE_OF]->(frodo);
Graph Databases
Use Cases
Recommended Not Recommended
Connected Data Cases where you update all (or a
subset) of entities
Routing, Dispatch, Location
based services
(because Global Graph Operations)
Recommendation Engines
Fraud Detection
Chart or Graph?
Chart or Graph?
image: giphy.com
Chart or Graph?
From Ancient Greek su x -γραφω (-graphō), from
γράφω (gráphō, “to scratch, to scrape, to graze”),
from whence also -graphy.
Wiktionary
Chart or Graph?
Every invariant and covariant thus becomes
expressible by a graph precisely identical with a
Kekuléan diagram or chemicograph.
JJ Sylvester, 1878
image: Wikipedia
Graph all the bridges
image: Wikipedia
Graph all the bridges
image: Wikipedia
Graph all the things: Make
all:foobarbaz
bar:
touchbar
foo:bar
touchfoo
baz:bar
touchbaz
Graph all the things: Make
digraphG{
n3[label="all",color="red"];
n5[label="bar",color="red"];
n6[label="baz",color="red"];
n2[label="examples/Makefile",color="green"];
n4[label="foo",color="red"];
n5->n3;
n6->n3;
n4->n3;
n5->n6;
n5->n4;
}
Graph all the things: Make
Graph all the things: Maven
Graph all the things: Git
http://www.cse.scu.edu/
Graph all the things: Linux
image: http://www.cse.scu.edu/
Story Time
(a convoluted Neo4j Demo)
Cool story
Cool story
digraphBook{
page1[label="You'reOnConcorde"];
page1->page6;
page6[label="Youmeetaliens"];
page6->page3 [label="Demandtogohome"];
page6->page4 [label="BondwithU-TY"];
page3[label="You'refeelingsleepy"];
page3->page5 [label="Haveanap"];
page3->page16[label="StayAwake"];
page3->page8 [label="YoumeetIncu"];
Cool graph
Cypher Query Language
Declarative, like SQL
Allows query or update of the graph
Built on ASCII art
Named after a Matrix character
Cypher Query Language
CREATE (page1:Beginning:Page{number:1,synopsis:'YouareonConcorde,andsomethingcomestowards
(page6:Page{number:6,synopsis:'Youininacircularroom'}),
(page3:Page{number:3,synopsis:'Youareinanotherroomwithotherpeople. Youarefeelingsleep
(page4:Page{number:4,synopsis:'YouasktheU-TYmastersaboutthemselves.'}),
page1-[:TURNS_TO]->page6,
page6-[:TURNS_TO{decision:'DemandtobetakentoEarth'}]->page3,
page6-[:TURNS_TO{decision:'AsktheU-TYaboutthemselves'}]->page4,
(page5:Page {number:4,synopsis:'Thereisabandonyourhead'}),
(page8:Page {number:8,synopsis:'YoumeetIncu,captivefromAlara'}),
(page16:Page{number:16,synopsis:'YoumeetIngmar,theSwedishkidfrom1682'}),
How many pages are there?
MATCH(p:Page)
RETURNcount(p)asPages;
+-------+
| Pages |
+-------+
| 80 |
+-------+
1 row
238 ms
How many endings are there?
match(e:Ending)
returncount(e)asEndings;
+---------+
| Endings |
+---------+
| 27 |
+---------+
1 row
25 ms
How many Decisions?
match(p1)-[r:TURNS_TO]->(p2)
wherehas(r.decision)
returncount(r.decision)asDecisions;
+-----------+
| Decisions |
+-----------+
| 59 |
+-----------+
1 row
198 ms
How many paths through the
book?
match(b:Beginning)-[r:TURNS_TO*]-(e:Ending)
returncount(b)asPaths;
+-------+
| Paths |
+-------+
| 125 |
+-------+
1 row
250 ms
What's the shortest path?
match(b:Beginning)-[r:TURNS_TO*]-(e:Ending)
returnlength(r)asLength,e.synopsisasEnding
orderbylength(r)
limit1;
+------------------------------------+
| Length | Ending |
+------------------------------------+
| 4 | "You fall asleep forever" |
+------------------------------------+
1 row
88 ms
What's the longest path?
match(b:Beginning)-[r:TURNS_TO*]-(e:Ending)
returnlength(r)asLength,e.synopsisasEnding
orderbylength(r)desc
limit1;
+--------------------------------------------------------------------------------+
|Length|Ending |
+--------------------------------------------------------------------------------+
|19 |"YousendtheU-TYontheirway,feelingguiltaboutabandoningIncu"|
+--------------------------------------------------------------------------------+
1row
138ms
What's in the shortest path?
match(b:Beginning),(e:Ending),
path=shortestPath((b)-[*]-(e))
returnnodes(path);
+---------------------------------------------------------
| [Node[20]{number:1,synopsis:"You are on Concorde, and so
| [Node[20]{number:1,synopsis:"You are on Concorde, and so
| [Node[20]{number:1,synopsis:"You are on Concorde, and so
Wat? Oh.
match(b:Beginning),(e:Ending),
path=shortestPath((b)-[*]-(e))
returnnodes(path)asShortestPath
limit1;
+----------------------------------------------------------------------------------------------------------------------
|ShortestPath|
+----------------------------------------------------------------------------------------------------------------------
|[Node[20]{number:1,synopsis:"YouareonConcorde,andsomethingcomestowardsyou"},Node[21]{number:6,synopsis:"Youi
+----------------------------------------------------------------------------------------------------------------------
Where is Ultima?
match(p:Page)
wherep.synopsis=~'.*Ultima.*'
returnp;
+-------------------------------------------------------------------+
|p |
+-------------------------------------------------------------------+
|Node[98]{number:101,synopsis:"YouFindUltima! Itisparadise."}|
+-------------------------------------------------------------------+
1row
5ms
What links to Ultima?
matchpage-[:TURNS_TO]->(p:Page{number:101})
returnpage;
+------+
| page |
+------+
+------+
0 row
4 ms
Does anything link to it?
matchn-[*]-(p:Page{number:101})
returnn,p;
+----------------------------------------------------------------------------------------------------------------------------
---------------------------------+
|n |p
|
+----------------------------------------------------------------------------------------------------------------------------
---------------------------------+
|Node[2684]{number:104,synopsis:"Yournewfriendsletyouhangoutanytimeyoulike"}|Node[2683]{number:101,synopsis:"You
FindUltima! Itisparadise."}|
+----------------------------------------------------------------------------------------------------------------------------
---------------------------------+
1row
10ms
Ultima Visualized
About Neo4j
Drivers for Java, Ruby, Python, Scala, Perl, Clojure (and more)
GPL Community edition
AGPL Enterprise
Written in Java and Scala
Open sourced in 2007
https://github.com/neo4j/neo4j
http://neo4j.com
Thank you
Questions?
@neo4j
@builddoctor
image: memegenerator
Circular Dependencies
create (alice:Person {name:"Alice"})-[:LOVES]->
(bob:Person {name:"Bob"}),
(bob)-[:LOVES]->(carol:Person {name:"Carol"}),
(carol)-[:LOVES]->(alice)
Circular Dependencies
match (n)-[:LOVES]->(m) return n.name,m.name
+-------------------+
| n.name | m.name |
+-------------------+
| "Alice" | "Bob" |
| "Bob" | "Carol" |
| "Carol" | "Alice" |
+-------------------+
6 rows
39 ms

Contenu connexe

Similaire à Surrounded by Graphs

The openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageThe openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query Language
Neo4j
 

Similaire à Surrounded by Graphs (20)

All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
All About GRAND Stack: GraphQL, React, Apollo, and Neo4j (Mark Needham) - Gre...
 
A general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4JA general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4J
 
Odessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and PythonOdessapy2013 - Graph databases and Python
Odessapy2013 - Graph databases and Python
 
TinkerPop: a story of graphs, DBs, and graph DBs
TinkerPop: a story of graphs, DBs, and graph DBsTinkerPop: a story of graphs, DBs, and graph DBs
TinkerPop: a story of graphs, DBs, and graph DBs
 
Creating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector GraphicsCreating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector Graphics
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
The openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageThe openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query Language
 
Apache Storm 0.9 basic training - Verisign
Apache Storm 0.9 basic training - VerisignApache Storm 0.9 basic training - Verisign
Apache Storm 0.9 basic training - Verisign
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
03 introduction to graph databases
03   introduction to graph databases03   introduction to graph databases
03 introduction to graph databases
 
Ehtsham Elahi, Senior Research Engineer, Personalization Science and Engineer...
Ehtsham Elahi, Senior Research Engineer, Personalization Science and Engineer...Ehtsham Elahi, Senior Research Engineer, Personalization Science and Engineer...
Ehtsham Elahi, Senior Research Engineer, Personalization Science and Engineer...
 
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
 
Scio - Moving to Google Cloud, A Spotify Story
 Scio - Moving to Google Cloud, A Spotify Story Scio - Moving to Google Cloud, A Spotify Story
Scio - Moving to Google Cloud, A Spotify Story
 
08lexi.pdf
08lexi.pdf08lexi.pdf
08lexi.pdf
 
HyperGraphQL
HyperGraphQLHyperGraphQL
HyperGraphQL
 
Demo Eclipse Science
Demo Eclipse ScienceDemo Eclipse Science
Demo Eclipse Science
 
Demo eclipse science
Demo eclipse scienceDemo eclipse science
Demo eclipse science
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
 
GraphQL & DGraph with Go
GraphQL & DGraph with GoGraphQL & DGraph with Go
GraphQL & DGraph with Go
 

Plus de Julian Simpson

Plus de Julian Simpson (7)

Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as code
 
Everything I learned about Continuous Integration, I learned from Systems Adm...
Everything I learned about Continuous Integration, I learned from Systems Adm...Everything I learned about Continuous Integration, I learned from Systems Adm...
Everything I learned about Continuous Integration, I learned from Systems Adm...
 
Continuous Integration, the minimum viable product
Continuous Integration, the minimum viable productContinuous Integration, the minimum viable product
Continuous Integration, the minimum viable product
 
Silos are for farmers
Silos are for farmersSilos are for farmers
Silos are for farmers
 
Lrug
LrugLrug
Lrug
 
Agile Systems Admin
Agile Systems AdminAgile Systems Admin
Agile Systems Admin
 
Ci From The Trenches
Ci From The TrenchesCi From The Trenches
Ci From The Trenches
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Surrounded by Graphs