SlideShare ist ein Scribd-Unternehmen logo
1 von 98
GeekOut
                   Tallinn
                  Estonia!




                             #neo4j
Peter Neubauer               @peterneubauer
Neo Technology               peter@neotechnology.com
First, a recap: NOSQL data models
             Key-value stores
 Data size




                           Column Family


                                           Document
                                           databases


                                                          Graph databases

                                                                            We are here




                                                       Data complexity
h"p://www.flickr.com/photos/crazyneighborlady/355232758/
h"p://gallery.nen.gov.uk/image82582‐.html
h"p://www.xtranormal.com/watch/6995033/mongo‐db‐is‐web‐scale
h"p://www.orangesmile.com/desFnaFons/img/berlin‐map‐metro‐big.gif
h"p://malden‐dsme.co.uk/public/hcj.html
h"p://easystreetdiscount.aucFvacommerce.com/Nirvana‐Smiley‐Face‐Music‐Band‐Decal‐SFcker‐P188162.aspx
h"p://www.tolkienlibrary.com/press/922‐Isildur_Poker_Champion.php
h"p://www.vaccineFmes.com/wp‐content/uploads/2010/12/microscope.jpg
username: Jeff1986   username: SallyDJ
                                          username: FunkySam    username: Gazza
      age: 25             age: 28
                                                age: 24             age: 32
 friend : SallyDJ    friend : Jeff1986
                                           friend : SallyDJ    friend : Jeff1986
  friend : Gazza      friend: FunkySam




                               Document
Database
username: SallyDJ
                                      age: 28




  username: Gazza                username: Jeff1986                   username: FunkySam
      age: 32                          age: 25                              age: 24

                                 ApplicaFon
Layer




                                         Reify
username: Jeff1986   username: SallyDJ
                                                 username: FunkySam         username: Gazza
      age: 25             age: 28
                                                       age: 24                  age: 32
 friend : SallyDJ    friend : Jeff1986
                                                  friend : SallyDJ         friend : Jeff1986
  friend : Gazza      friend: FunkySam




                               Document
Database
username: SallyDJ
                                  age: 28

                                                 FRI




                                   FRIEND
                                                    END



                  FRIEND
username: Gazza             username: Jeff1986         username: FunkySam
    age: 32                       age: 25                    age: 24

                           Graph
Database
h"p://www.freewebs.com/ficFonfrek101/han.jpg
username: Gazza                         username: SallyDJ
                            age: 32                                  age: 28




                             PURCHASED




                                                                             PURCHASED
                                                         ED
                                                     CHAS
                                                 PUR



                       product: SuperCans                       product: CoolDecks
                      manufacturer : Acme                      manufacturer : Acme
                           price : 150                              price : 599

                                          Graph
Database




product: SuperCans         product: CoolDecks              username:   SallyDJ
                                                                                            username: Gazza
                                                                age:   28
                                                                                                age: 32
manufacturer : Acme        manufacturer : Acme           purchased :   CoolDecks
                                                                                         purchased : SuperCans
    price : 150                price : 599               purchased :   SuperCans




                                         Document
Database
The Neo4j model: Property Graph
The Neo4j model: Property Graph



             1          2




                    3
The Neo4j model: Property Graph



             1          2




                    3
The Neo4j model: Property Graph
                           name = “Emil”
                           age = 29
                           sex = “yes”




                       1                         2



      type = KNOWS
      time = 4 years                       3

                                               type = car
                                               vendor = “SAAB”
                                               model = “95 Aero”
Building a node space (core API)
Building a node space (core API)
GraphDatabaseService graphDb = ... // Get factory


// Create Thomas 'Neo' Anderson
Node mrAnderson = graphDb.createNode();
mrAnderson.setProperty( "name", "Thomas Anderson" );
mrAnderson.setProperty( "age", 29 );

// Create Morpheus
Node morpheus = graphDb.createNode();
morpheus.setProperty( "name", "Morpheus" );
morpheus.setProperty( "rank", "Captain" );
morpheus.setProperty( "occupation", "Total bad ass" );

// Create a relationship representing that they know each other
mrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS );
// ...create Trinity, Cypher, Agent Smith, Architect similarly
Building a node space
GraphDatabaseService graphDb = ... // Get factory
Transaction tx = graphdb.beginTx();

// Create Thomas 'Neo' Anderson
Node mrAnderson = graphDb.createNode();
mrAnderson.setProperty( "name", "Thomas Anderson" );
mrAnderson.setProperty( "age", 29 );

// Create Morpheus
Node morpheus = graphDb.createNode();
morpheus.setProperty( "name", "Morpheus" );
morpheus.setProperty( "rank", "Captain" );
morpheus.setProperty( "occupation", "Total bad ass" );

// Create a relationship representing that they know each other
mrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS );
// ...create Trinity, Cypher, Agent Smith, Architect similarly
tx.commit();
We want answers!
// Instantiate a traverser that returns Mr Anderson's friends
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );

// Traverse the node space and print out the result
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );

// Traverse the node space and print out the result
System.out.println( "Mr Anderson's friends:" );
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );

// Traverse the node space and print out the result
System.out.println( "Mr Anderson's friends:" );
for ( Node friend : friendsTraverser )
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );

// Traverse the node space and print out the result
System.out.println( "Mr Anderson's friends:" );
for ( Node friend : friendsTraverser )
{
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );

// Traverse the node space and print out the result
System.out.println( "Mr Anderson's friends:" );
for ( Node friend : friendsTraverser )
{
     System.out.printf( "At depth %d => %s%n",
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );

// Traverse the node space and print out the result
System.out.println( "Mr Anderson's friends:" );
for ( Node friend : friendsTraverser )
{
     System.out.printf( "At depth %d => %s%n",
           friendsTraverser.currentPosition().getDepth(),
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );

// Traverse the node space and print out the result
System.out.println( "Mr Anderson's friends:" );
for ( Node friend : friendsTraverser )
{
     System.out.printf( "At depth %d => %s%n",
           friendsTraverser.currentPosition().getDepth(),
           friend.getProperty( "name" ) );
// Instantiate a traverser that returns Mr Anderson's friends
Traverser friendsTraverser = mrAnderson.traverse(
     Traverser.Order.BREADTH_FIRST,
     StopEvaluator.END_OF_GRAPH,
     ReturnableEvaluator.ALL_BUT_START_NODE,
     RelTypes.KNOWS,
     Direction.OUTGOING );

// Traverse the node space and print out the result
System.out.println( "Mr Anderson's friends:" );
for ( Node friend : friendsTraverser )
{
     System.out.printf( "At depth %d => %s%n",
           friendsTraverser.currentPosition().getDepth(),
           friend.getProperty( "name" ) );
}
gem install neo4j
gem install neo4j

require ”rubygems”
gem install neo4j

require ”rubygems”
require 'neo4j'
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
end
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
end

Neo4j::Transactoin.run do
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
end

Neo4j::Transactoin.run do
  neo = Person.new :name=>'Neo', :age=>29
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
end

Neo4j::Transactoin.run do
  neo = Person.new :name=>'Neo', :age=>29
  morpheus = Person.new :name=>'Morpheus', :occupation=>'badass'
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
end

Neo4j::Transactoin.run do
  neo = Person.new :name=>'Neo', :age=>29
  morpheus = Person.new :name=>'Morpheus', :occupation=>'badass'
  neo.friends << morpheus
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
end

Neo4j::Transactoin.run do
  neo = Person.new :name=>'Neo', :age=>29
  morpheus = Person.new :name=>'Morpheus', :occupation=>'badass'
  neo.friends << morpheus
end
gem install neo4j

require ”rubygems”
require 'neo4j'

class Person
  include Neo4j::NodeMixin
  property :name, :age, :occupation
  index :name
  has_n :friends
end

Neo4j::Transactoin.run do
  neo = Person.new :name=>'Neo', :age=>29
  morpheus = Person.new :name=>'Morpheus', :occupation=>'badass'
  neo.friends << morpheus
end

neo.friends.each {|p|...}
Cypher - Pattern Matcing für alle
Cypher - Pattern Matcing für alle
//All nodes related to n
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)-
[:KNOWS]-(c)
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)-
[:KNOWS]-(c)
return a,b,c,d
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)-
[:KNOWS]-(c)
return a,b,c,d

//Where RegExp
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)-
[:KNOWS]-(c)
return a,b,c,d

//Where RegExp
start n=(2, 1) where n.name =~ /Tob.*/ return n
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)-
[:KNOWS]-(c)
return a,b,c,d

//Where RegExp
start n=(2, 1) where n.name =~ /Tob.*/ return n

//FOAF
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)-
[:KNOWS]-(c)
return a,b,c,d

//Where RegExp
start n=(2, 1) where n.name =~ /Tob.*/ return n

//FOAF
start user = (people-index,name,”John”)
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)-
[:KNOWS]-(c)
return a,b,c,d

//Where RegExp
start n=(2, 1) where n.name =~ /Tob.*/ return n

//FOAF
start user = (people-index,name,”John”)
match (user)-[:friend]->()-[:friend]->(foaf)
Cypher - Pattern Matcing für alle
//All nodes related to n
start n=(3) match (n)--(x) return x

//All nodes that are BLOCKed by A
start n=(3) match (n)-[:BLOCKS]->(x) return x

//All BLOCKS relationships outgoing from n
start n=(3) match (n)-[r, :BLOCKS]->() return r

//Diamond shape pattern
start a=(3)
match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)-
[:KNOWS]-(c)
return a,b,c,d

//Where RegExp
start n=(2, 1) where n.name =~ /Tob.*/ return n

//FOAF
start user = (people-index,name,”John”)
match (user)-[:friend]->()-[:friend]->(foaf)
return user, foaf
g = new Neo4jGraph('/tmp/neo4j')
g = new Neo4jGraph('/tmp/neo4j')

// calculate basic collaborative filtering for vertex
1
g = new Neo4jGraph('/tmp/neo4j')

// calculate basic collaborative filtering for vertex
1
m = [:]
g = new Neo4jGraph('/tmp/neo4j')

// calculate basic collaborative filtering for vertex
1
m = [:]
g.v(1).out('likes').in('likes').out('likes').groupCou
nt(m)
g = new Neo4jGraph('/tmp/neo4j')

// calculate basic collaborative filtering for vertex
1
m = [:]
g.v(1).out('likes').in('likes').out('likes').groupCou
nt(m)
m.sort{a,b -> a.value <=> b.value}
So - what do I use this for?
Financial data – fraud detection
                                                                               name = ...

                                 name = “The Tavern”
                                 lat = 1295238237
name = “Mr Godfather”
                                 long = 234823492
                                                                                                  W
                                                                                                            42
karma = veeeery-low
                                                                                              D RA
cash = more-than-you                                    amount = $1000                      H
                                                                                         IT
                                                                                        W
                  OWNS                                  TRANSFER                        WIT
     1                                        7                            3                    HDR
                                                                                                      AW
                                                                                                               13

                                                  FER
                  DE                                           name = “Emil”
                    PO                                         cash = always-too-li'l
                                              TRANS
                        SI
                             T
                                                                                                           title = “ATM @ Wall St”
                                                                                                           id = 230918484233
       amount = $1000                                                                                      cash_left = 384204
                                        2

                                 name = ...
Routing
h"p://www.transportdublin.ie/
‐
Paddy
Fitzgerald
on
Neo4j
Social graphs

 Recommendations
 Location based
 services
 Influencers
 Shortest path
Impact Analytics, CMDB, Network
Management, Provisioning
Impact Analytics, CMDB, Network
Management, Provisioning
Master Data Management
Master Data Management
Master Data Management
Multiple indexes - GIS
Neo4j dynamic layers
                          Geometry                    Layer1
                          Encoder
                          Dynamic
                           Query                      Layer2
                          Dynamic
                           Styles                     Layer3
                          Dynamic
                          Meta-Inf


Connected domain data   Neo4j Spatial   GIS and Spatial stacks
OpenStreetMap
Cell network analysis
Text
                                 Text




http://test.eeni.tbm.tudelft.nl/~alfredas/d13n-graph.png
Demo time!




             Image credit: lost again! Sorry :(
“Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch. http://lod-cloud.net/”
http://neotechnology.com   43

Weitere ähnliche Inhalte

Mehr von Peter Neubauer

Neo4j at @PolyglotVancouver
Neo4j at @PolyglotVancouverNeo4j at @PolyglotVancouver
Neo4j at @PolyglotVancouverPeter Neubauer
 
Tips for building communitites with limited resources
Tips for building communitites with limited resourcesTips for building communitites with limited resources
Tips for building communitites with limited resourcesPeter Neubauer
 
Intro to Neo4j or why insurances should love graphs
Intro to Neo4j or why insurances should love graphsIntro to Neo4j or why insurances should love graphs
Intro to Neo4j or why insurances should love graphsPeter Neubauer
 
Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Peter Neubauer
 
GDM 2011 - Neo4j and real world apps.
GDM 2011 - Neo4j and real world apps.GDM 2011 - Neo4j and real world apps.
GDM 2011 - Neo4j and real world apps.Peter Neubauer
 
2010 09-neo4j-deutsche-telekom
2010 09-neo4j-deutsche-telekom2010 09-neo4j-deutsche-telekom
2010 09-neo4j-deutsche-telekomPeter Neubauer
 
Neo4j spatial-nosql-frankfurt
Neo4j spatial-nosql-frankfurtNeo4j spatial-nosql-frankfurt
Neo4j spatial-nosql-frankfurtPeter Neubauer
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesPeter Neubauer
 

Mehr von Peter Neubauer (9)

Neo4j at @PolyglotVancouver
Neo4j at @PolyglotVancouverNeo4j at @PolyglotVancouver
Neo4j at @PolyglotVancouver
 
Tips for building communitites with limited resources
Tips for building communitites with limited resourcesTips for building communitites with limited resources
Tips for building communitites with limited resources
 
Intro to Neo4j or why insurances should love graphs
Intro to Neo4j or why insurances should love graphsIntro to Neo4j or why insurances should love graphs
Intro to Neo4j or why insurances should love graphs
 
2011 11-öredev
2011 11-öredev2011 11-öredev
2011 11-öredev
 
Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.
 
GDM 2011 - Neo4j and real world apps.
GDM 2011 - Neo4j and real world apps.GDM 2011 - Neo4j and real world apps.
GDM 2011 - Neo4j and real world apps.
 
2010 09-neo4j-deutsche-telekom
2010 09-neo4j-deutsche-telekom2010 09-neo4j-deutsche-telekom
2010 09-neo4j-deutsche-telekom
 
Neo4j spatial-nosql-frankfurt
Neo4j spatial-nosql-frankfurtNeo4j spatial-nosql-frankfurt
Neo4j spatial-nosql-frankfurt
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examples
 

Kürzlich hochgeladen

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 

Kürzlich hochgeladen (20)

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 

Geekout Tallinn - Neo4j for the rescue!

  • 1. GeekOut Tallinn Estonia! #neo4j Peter Neubauer @peterneubauer Neo Technology peter@neotechnology.com
  • 2. First, a recap: NOSQL data models Key-value stores Data size Column Family Document databases Graph databases We are here Data complexity
  • 11. username: Jeff1986 username: SallyDJ username: FunkySam username: Gazza age: 25 age: 28 age: 24 age: 32 friend : SallyDJ friend : Jeff1986 friend : SallyDJ friend : Jeff1986 friend : Gazza friend: FunkySam Document
Database
  • 12. username: SallyDJ age: 28 username: Gazza username: Jeff1986 username: FunkySam age: 32 age: 25 age: 24 ApplicaFon
Layer Reify username: Jeff1986 username: SallyDJ username: FunkySam username: Gazza age: 25 age: 28 age: 24 age: 32 friend : SallyDJ friend : Jeff1986 friend : SallyDJ friend : Jeff1986 friend : Gazza friend: FunkySam Document
Database
  • 13. username: SallyDJ age: 28 FRI FRIEND END FRIEND username: Gazza username: Jeff1986 username: FunkySam age: 32 age: 25 age: 24 Graph
Database
  • 15. username: Gazza username: SallyDJ age: 32 age: 28 PURCHASED PURCHASED ED CHAS PUR product: SuperCans product: CoolDecks manufacturer : Acme manufacturer : Acme price : 150 price : 599 Graph
Database product: SuperCans product: CoolDecks username: SallyDJ username: Gazza age: 28 age: 32 manufacturer : Acme manufacturer : Acme purchased : CoolDecks purchased : SuperCans price : 150 price : 599 purchased : SuperCans Document
Database
  • 16. The Neo4j model: Property Graph
  • 17. The Neo4j model: Property Graph 1 2 3
  • 18. The Neo4j model: Property Graph 1 2 3
  • 19. The Neo4j model: Property Graph name = “Emil” age = 29 sex = “yes” 1 2 type = KNOWS time = 4 years 3 type = car vendor = “SAAB” model = “95 Aero”
  • 20. Building a node space (core API)
  • 21. Building a node space (core API) GraphDatabaseService graphDb = ... // Get factory // Create Thomas 'Neo' Anderson Node mrAnderson = graphDb.createNode(); mrAnderson.setProperty( "name", "Thomas Anderson" ); mrAnderson.setProperty( "age", 29 ); // Create Morpheus Node morpheus = graphDb.createNode(); morpheus.setProperty( "name", "Morpheus" ); morpheus.setProperty( "rank", "Captain" ); morpheus.setProperty( "occupation", "Total bad ass" ); // Create a relationship representing that they know each other mrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS ); // ...create Trinity, Cypher, Agent Smith, Architect similarly
  • 22. Building a node space GraphDatabaseService graphDb = ... // Get factory Transaction tx = graphdb.beginTx(); // Create Thomas 'Neo' Anderson Node mrAnderson = graphDb.createNode(); mrAnderson.setProperty( "name", "Thomas Anderson" ); mrAnderson.setProperty( "age", 29 ); // Create Morpheus Node morpheus = graphDb.createNode(); morpheus.setProperty( "name", "Morpheus" ); morpheus.setProperty( "rank", "Captain" ); morpheus.setProperty( "occupation", "Total bad ass" ); // Create a relationship representing that they know each other mrAnderson.createRelationshipTo( morpheus, RelTypes.KNOWS ); // ...create Trinity, Cypher, Agent Smith, Architect similarly tx.commit();
  • 24.
  • 25. // Instantiate a traverser that returns Mr Anderson's friends
  • 26. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse(
  • 27. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST,
  • 28. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH,
  • 29. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE,
  • 30. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS,
  • 31. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING );
  • 32. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result
  • 33. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result System.out.println( "Mr Anderson's friends:" );
  • 34. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result System.out.println( "Mr Anderson's friends:" ); for ( Node friend : friendsTraverser )
  • 35. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result System.out.println( "Mr Anderson's friends:" ); for ( Node friend : friendsTraverser ) {
  • 36. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result System.out.println( "Mr Anderson's friends:" ); for ( Node friend : friendsTraverser ) { System.out.printf( "At depth %d => %s%n",
  • 37. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result System.out.println( "Mr Anderson's friends:" ); for ( Node friend : friendsTraverser ) { System.out.printf( "At depth %d => %s%n", friendsTraverser.currentPosition().getDepth(),
  • 38. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result System.out.println( "Mr Anderson's friends:" ); for ( Node friend : friendsTraverser ) { System.out.printf( "At depth %d => %s%n", friendsTraverser.currentPosition().getDepth(), friend.getProperty( "name" ) );
  • 39. // Instantiate a traverser that returns Mr Anderson's friends Traverser friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, Direction.OUTGOING ); // Traverse the node space and print out the result System.out.println( "Mr Anderson's friends:" ); for ( Node friend : friendsTraverser ) { System.out.printf( "At depth %d => %s%n", friendsTraverser.currentPosition().getDepth(), friend.getProperty( "name" ) ); }
  • 40.
  • 42. gem install neo4j require ”rubygems”
  • 43. gem install neo4j require ”rubygems” require 'neo4j'
  • 44. gem install neo4j require ”rubygems” require 'neo4j' class Person
  • 45. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin
  • 46. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation
  • 47. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name
  • 48. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends
  • 49. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends end
  • 50. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends end Neo4j::Transactoin.run do
  • 51. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends end Neo4j::Transactoin.run do neo = Person.new :name=>'Neo', :age=>29
  • 52. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends end Neo4j::Transactoin.run do neo = Person.new :name=>'Neo', :age=>29 morpheus = Person.new :name=>'Morpheus', :occupation=>'badass'
  • 53. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends end Neo4j::Transactoin.run do neo = Person.new :name=>'Neo', :age=>29 morpheus = Person.new :name=>'Morpheus', :occupation=>'badass' neo.friends << morpheus
  • 54. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends end Neo4j::Transactoin.run do neo = Person.new :name=>'Neo', :age=>29 morpheus = Person.new :name=>'Morpheus', :occupation=>'badass' neo.friends << morpheus end
  • 55. gem install neo4j require ”rubygems” require 'neo4j' class Person include Neo4j::NodeMixin property :name, :age, :occupation index :name has_n :friends end Neo4j::Transactoin.run do neo = Person.new :name=>'Neo', :age=>29 morpheus = Person.new :name=>'Morpheus', :occupation=>'badass' neo.friends << morpheus end neo.friends.each {|p|...}
  • 56. Cypher - Pattern Matcing für alle
  • 57. Cypher - Pattern Matcing für alle //All nodes related to n
  • 58. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x
  • 59. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A
  • 60. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x
  • 61. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n
  • 62. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r
  • 63. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern
  • 64. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3)
  • 65. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)- [:KNOWS]-(c)
  • 66. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)- [:KNOWS]-(c) return a,b,c,d
  • 67. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)- [:KNOWS]-(c) return a,b,c,d //Where RegExp
  • 68. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)- [:KNOWS]-(c) return a,b,c,d //Where RegExp start n=(2, 1) where n.name =~ /Tob.*/ return n
  • 69. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)- [:KNOWS]-(c) return a,b,c,d //Where RegExp start n=(2, 1) where n.name =~ /Tob.*/ return n //FOAF
  • 70. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)- [:KNOWS]-(c) return a,b,c,d //Where RegExp start n=(2, 1) where n.name =~ /Tob.*/ return n //FOAF start user = (people-index,name,”John”)
  • 71. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)- [:KNOWS]-(c) return a,b,c,d //Where RegExp start n=(2, 1) where n.name =~ /Tob.*/ return n //FOAF start user = (people-index,name,”John”) match (user)-[:friend]->()-[:friend]->(foaf)
  • 72. Cypher - Pattern Matcing für alle //All nodes related to n start n=(3) match (n)--(x) return x //All nodes that are BLOCKed by A start n=(3) match (n)-[:BLOCKS]->(x) return x //All BLOCKS relationships outgoing from n start n=(3) match (n)-[r, :BLOCKS]->() return r //Diamond shape pattern start a=(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:BLOCKS]-(d)- [:KNOWS]-(c) return a,b,c,d //Where RegExp start n=(2, 1) where n.name =~ /Tob.*/ return n //FOAF start user = (people-index,name,”John”) match (user)-[:friend]->()-[:friend]->(foaf) return user, foaf
  • 73.
  • 74. g = new Neo4jGraph('/tmp/neo4j')
  • 75. g = new Neo4jGraph('/tmp/neo4j') // calculate basic collaborative filtering for vertex 1
  • 76. g = new Neo4jGraph('/tmp/neo4j') // calculate basic collaborative filtering for vertex 1 m = [:]
  • 77. g = new Neo4jGraph('/tmp/neo4j') // calculate basic collaborative filtering for vertex 1 m = [:] g.v(1).out('likes').in('likes').out('likes').groupCou nt(m)
  • 78. g = new Neo4jGraph('/tmp/neo4j') // calculate basic collaborative filtering for vertex 1 m = [:] g.v(1).out('likes').in('likes').out('likes').groupCou nt(m) m.sort{a,b -> a.value <=> b.value}
  • 79. So - what do I use this for?
  • 80. Financial data – fraud detection name = ... name = “The Tavern” lat = 1295238237 name = “Mr Godfather” long = 234823492 W 42 karma = veeeery-low D RA cash = more-than-you amount = $1000 H IT W OWNS TRANSFER WIT 1 7 3 HDR AW 13 FER DE name = “Emil” PO cash = always-too-li'l TRANS SI T title = “ATM @ Wall St” id = 230918484233 amount = $1000 cash_left = 384204 2 name = ...
  • 83. Social graphs Recommendations Location based services Influencers Shortest path
  • 84. Impact Analytics, CMDB, Network Management, Provisioning
  • 85. Impact Analytics, CMDB, Network Management, Provisioning
  • 90. Neo4j dynamic layers Geometry Layer1 Encoder Dynamic Query Layer2 Dynamic Styles Layer3 Dynamic Meta-Inf Connected domain data Neo4j Spatial GIS and Spatial stacks
  • 92.
  • 94. Text Text http://test.eeni.tbm.tudelft.nl/~alfredas/d13n-graph.png
  • 95.
  • 96. Demo time! Image credit: lost again! Sorry :(
  • 97. “Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch. http://lod-cloud.net/”

Hinweis der Redaktion

  1. \n
  2. \n
  3. We have key-value stores, typically very highly available and scalable for simple key-value data\n
  4. Column stores naturally-indexed value stores\n\nContrary to common belief &amp;#x2013; Google&amp;#x2019;s big table isn&amp;#x2019;t the world&amp;#x2019;s most famous column store\n\nBritish museum London is: it&amp;#x2019;s got columns and it&amp;#x2019;s where we stored all the stuff we nicked from the British Empire!\n
  5. Document DB&amp;#x2019;s support for large-scale document storage, indexing documents, and processing them with batch-oriented frameworks.\n
  6. We have graph databases that are well suited to complex, interconnected data\n\nSide note: Graph DB&amp;#x2019;s are unique in the NOSQL world, that they&amp;#x2019;re the only class of store that has a more expressive data model than RDBMS &amp;#x2013; all the others have gone for simpler data models to achieve scale/availability/throughput\n
  7. Each database pulls various levers to achieve its aims:\n\nDurable -&gt; ordered writes -&gt; take your chances\nSharded -&gt; replicated -&gt; take your chances\nConsistent -&gt; eventually consistent -&gt; take your chances\n\nNeo4j takes the ACID always approach\n
  8. We should be in data-Nirvana\n\nWe have a range of data models to choose from\nWe have a range of products to select that support those models\nWe have a range of tuning that we can apply to those products \n\nWe should be able to craft exactly the right platform for our data needs\n
  9. And then we fall back on old habits: trying to find the one true Database to rule them all. \n*sigh*\n\nKV stores pushing up against Document stores\nColumn stores pushing up against KV stores\nDocument stores wading into graphs\n\nAnd all the time all four NOSQL models are being poorly grafted onto our deal old RDMBS&amp;#x2019;es!\n
  10. Let&amp;#x2019;s take a closer look at the damage we&amp;#x2019;re doing\n
  11. We can encode shallow graph-like data in document stores if we like (or even RDBMS like twitter)\n\nIt starts off looking nice and easy!\n
  12. At runtime the application code sucks in the data and reifies a graph.\n\nOK, so that&amp;#x2019;s code you have to test and write, but the datamodel is just documents, so that&amp;#x2019;s OK right?\n
  13. Compared to a graph database, it&amp;#x2019;s actually hard work\n\nA graph DB stores data naturally in graphs so you don&amp;#x2019;t have to deal with that concern in your code &amp;#x2013; you deal with true application concerns \n\n-&gt; index free traversal of big data FAST\n
  14. I&amp;#x2019;ve got a bad feeling about this&amp;#x2026;\n
  15. Imagine we want to sell things to our little social network\n\nIn a graph it&amp;#x2019;s easy to record purchase history as relationships between buyers and products (and it doesn&amp;#x2019;t slow down as buyers and products grow in number unlike joins in a relational DB)\n\nIn a document DB, the structure is implicit, and it&amp;#x2019;s up to our application code to make sense of it.\nWhat do we do here? Put buyers in the product documents? Products in the people documents? Create purchase documents that join the two?\n\nWhat about a product recall, or social selling (example later on)?\nIn a graph DB it&amp;#x2019;s O(1) search operation to find out who bought a product.\nIn a document DB it&amp;#x2019;s an O(N) compute job to figure this out\n
  16. EE\n
  17. EE\n
  18. EE\n
  19. Lightweight and embedded: single jar of ~500k [demo]\n
  20. Fully transactional: ie complete ACID, supports JTA/JTS, 2PC, deadlock detection, transaction recovery and all the rest [demo]\n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. Graphs over 1M nodes\nNetwork Management\nMaster Data Management\nSocial\nFinance\nSpatial\nOther\nBioinformatics\nRDF\nRouting, Logistics\n\n
  76. Storage:\nplugable &amp;#x2013; dataset, layer, encoder\nSearch:\nIndexing is currently an R-Tree, but it is possible to plug in any custom mechanism conforming to the interface.\nMulti-dimensional index\nSpatial indices (quad-tree, R-tree, kn-tree, SFCs)\nComposite indices and dynamic indices\nLucene\n
  77. EE\n
  78. &amp;#x2022; includes high performance graph algorithms\n&amp;#x2022; routes with live changing data \n&amp;#x2022; integrates easily with any domain graph\n
  79. We have graph databases that are well suited to complex, interconnected data\n\nSide note: Graph DB&amp;#x2019;s are unique in the NOSQL world, that they&amp;#x2019;re the only class of store that has a more expressive data model than RDBMS &amp;#x2013; all the others have gone for simpler data models to achieve scale/availability/throughput\n
  80. &amp;#x2022; traverses millions of friends per second\n&amp;#x2022; maps directly to friend-of-a-friend\n&amp;#x2022; quickly performs deep recommendations\n
  81. &amp;#x2022; explores what-if failures\n&amp;#x2022; reveals root cause\n&amp;#x2022; determines actual operating cost\n
  82. &amp;#x2022; explores what-if failures\n&amp;#x2022; reveals root cause\n&amp;#x2022; determines actual operating cost\n
  83. &amp;#x2022; can handle billions of ad-hoc relationships \n&amp;#x2022; traverses millions of nodes per second\n&amp;#x2022; maps directly to your MDM domain\n
  84. &amp;#x2022; can handle billions of ad-hoc relationships \n&amp;#x2022; traverses millions of nodes per second\n&amp;#x2022; maps directly to your MDM domain\n
  85. &amp;#x2022; can handle billions of ad-hoc relationships \n&amp;#x2022; traverses millions of nodes per second\n&amp;#x2022; maps directly to your MDM domain\n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. Storage:\nplugable &amp;#x2013; dataset, layer, encoder\nSearch:\nIndexing is currently an R-Tree, but it is possible to plug in any custom mechanism conforming to the interface.\nMulti-dimensional index\nSpatial indices (quad-tree, R-tree, kn-tree, SFCs)\nComposite indices and dynamic indices\nLucene\n
  96. \n
  97. \n