SlideShare a Scribd company logo
1 of 38
Download to read offline
No SQL?




          Image credit: http://browsertoolkit.com/fault-tolerance.png
Neo4j   the benefits of
                graph databases



                                   #neo4j
Peter Neubauer                     @peterneubauer
COO, Neo Technology                peter@neotechnology.com
Why NoSQL 2009?

 Trend 1: Size.

 Trend 2: Connectivity.

 Trend 3: Semi-structure.

 Trend 4: Architecture.
NOSQL data models
            Key-value stores
Data size




                          Bigtable clones


                                            Document
                                            databases


                                                           Graph databases




                                                        Data complexity
NOSQL data models
               Key-value stores
   Data size




                             Bigtable clones


                                               Document
                                               databases


                                                              Graph databases

                                                                          (This is still b i l l i on s of
 90%                                                                      nodes & relationships)
  of
 use
cases




                                                           Data complexity
Graph DBs
& Neo4j intro
The Graph DB model: representation
 Core abstractions:
                                              name = “Emil”

   Nodes
                                              age = 29
                                              sex = “yes”


   Relationships between nodes
   Properties on both                     1                         2



                         type = KNOWS
                         time = 4 years                       3

                                                                  type = car
                                                                  vendor = “SAAB”
                                                                  model = “95 Aero”
Example: The Matrix
                                                                           name = “The Architect”
                             name = “Morpheus”
                             rank = “Captain”
name = “Thomas Anderson”
                             occupation = “Total badass”                                            42
age = 29
                                                 disclosure = public


                 KNOWS                            KNOWS                                              CODED_BY
                                                                                KNO
     1                                  7                              3           W   S

                 KN
                                                                                                13
                                             S

                    OW                                   name = “Cypher”
                                        KNOW



                         S                               last name = “Reagan”
                                                                                             name = “Agent Smith”
                                                                       disclosure = secret   version = 1.0b
         age = 3 days                                                  age = 6 months        language = C++
                                    2

                             name = “Trinity”
Code (1): Building a node space
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
Code (1): 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();
Code (1b): Def ning RelationshipTypes
             i
// In package org.neo4j.graphdb
public interface RelationshipType
{
   String name();
}

// In package org.yourdomain.yourapp
// Example on how to roll dynamic RelationshipTypes
RelationshipsType myRelType = DynamicRelatoinshipType.
                                     withName(“myRelType”);

// Example on how to kick it, static-RelationshipType-like
enum MyStaticRelTypes implements RelationshipType
{
   KNOWS,
   WORKS_FOR,
}
Whiteboard friendly



                                 owns
                      Björn                  Big Car
                        build             drives


                                DayCare
The Graph DB model: traversal
 Traverser framework for
 high-performance traversing                    name = “Emil”
                                                age = 31

 across the node space                          sex = “yes”




                                            1                         2



                           type = KNOWS
                           time = 4 years                       3

                                                                    type = car
                                                                    vendor = “SAAB”
                                                                    model = “95 Aero”
Example: Mr Anderson’s friends
                                                                           name = “The Architect”
                             name = “Morpheus”
                             rank = “Captain”
name = “Thomas Anderson”
                             occupation = “Total badass”                                            42
age = 29
                                                 disclosure = public


                 KNOWS                            KNOWS                                              CODED_BY
                                                                                KNO
     1                                  7                              3           W   S

                 KN
                                                                                                13
                                             S

                    OW                                   name = “Cypher”
                                        KNOW



                         S                               last name = “Reagan”
                                                                                             name = “Agent Smith”
                                                                       disclosure = secret   version = 1.0b
         age = 3 days                                                  age = 6 months        language = C++
                                    2

                             name = “Trinity”
Code (2): Traversing a node space
// 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" ) );
}
name = “The Architect”
                              name = “Morpheus”
                              rank = “Captain”
 name = “Thomas Anderson”
                              occupation = “Total badass”                                            42
 age = 29
                                                  disclosure = public


                  KNOWS                            KNOWS                                              CODED_BY
                                                                                 KNO
      1                                  7                              3           W     S

                  KN                                                                              13

                                              S
                     OW                                   name = “Cypher”

                                         KNOW
                          S                               last name = “Reagan”
                                                                                               name = “Agent Smith”
                                                                        disclosure = secret    version = 1.0b
          age = 3 days                                                  age = 6 months         language = C++
                                     2

                              name = “Trinity”
                                                                    $ bin/start-neo-example
                                                                    Mr Anderson's friends:

                                                                    At      depth     1   =>   Morpheus
friendsTraverser = mrAnderson.traverse(
  Traverser.Order.BREADTH_FIRST,                                    At      depth     1   =>   Trinity
  StopEvaluator.END_OF_GRAPH,                                       At      depth     2   =>   Cypher
  ReturnableEvaluator.ALL_BUT_START_NODE,
  RelTypes.KNOWS,
                                                                    At      depth     3   =>   Agent Smith
  Direction.OUTGOING );                                             $
Example: Friends in love?
                                                                             name = “The Architect”
                               name = “Morpheus”
                               rank = “Captain”
name = “Thomas Anderson”
                               occupation = “Total badass”                                            42
age = 29
                                                   disclosure = public


                   KNOWS                            KNOWS                                              CODED_BY
                                                                                  KNO
     1                                    7                              3           W   S

                   KN                                                                             13
                                               S
                                          KNOW


                      OW                                   name = “Cypher”
                           S                               last name = “Reagan”
                                                                                               name = “Agent Smith”
         LO                                                              disclosure = secret   version = 1.0b
            VE                                                           age = 6 months        language = C++
               S
                                      2

                               name = “Trinity”
Code (3a): Custom traverser
// Create a traverser that returns all “friends in love”
Traverser loveTraverser = mrAnderson.traverse(
   Traverser.Order.BREADTH_FIRST,
   StopEvaluator.END_OF_GRAPH,
   new ReturnableEvaluator()
   {
       public boolean isReturnableNode( TraversalPosition pos )
       {
          return pos.currentNode().hasRelationship(
              RelTypes.LOVES, Direction.OUTGOING );
       }
   },
   RelTypes.KNOWS,
   Direction.OUTGOING );
Code (3a): Custom traverser
// Traverse the node space and print out the result
System.out.println( "Who’s a lover?" );
for ( Node person : loveTraverser )
{
   System.out.printf( "At depth %d => %s%n",
       loveTraverser.currentPosition().getDepth(),
       person.getProperty( "name" ) );
}
name = “The Architect”
                                name = “Morpheus”
                                rank = “Captain”
 name = “Thomas Anderson”
                                occupation = “Total badass”                                            42
 age = 29
                                                    disclosure = public


                    KNOWS                            KNOWS                         KNO                  CODED_BY
      1                                    7                              3           W   S

                    KN                                                                             13

                                                S
                                                            name = “Cypher”

                                           KNOW
                       OW
                            S                               last name = “Reagan”
                                                                                                name = “Agent Smith”
          LO                                                              disclosure = secret   version = 1.0b
             VE                                                           age = 6 months        language = C++
                S
                                       2

                                name = “Trinity”
                                                                     $ bin/start-neo-example
new ReturnableEvaluator()
                                                                     Who’s a lover?
{
  public boolean isReturnableNode(
    TraversalPosition pos)
                                                                     At depth 1 => Trinity
  {                                                                  $
    return pos.currentNode().
      hasRelationship( RelTypes.LOVES,
         Direction.OUTGOING );
  }
},
Domain layer frameworks
 Spring (SpringDM, Grails, Griffon etc), Sling, Karaf
 Rails, Django
 Qi4j (www.qi4j.org)
    Framework for doing DDD in pure Java5
    Def nes Entities / Associations / Properties
       i
       Sound familiar? Nodes / Rel’s / Properties!
    Neo4j is an “EntityStore” backend

 Jo4neo (http://code.google.com/p/jo4neo)
    Annotation driven
    Weaves Neo4j-backed persistence into domain objects
    at runtime
Code (4): Groovy/Grails
import grails.plugins.neo4j.*
@Neo4jEntity
class Author {

    @Neo4jIndex
    String name
}
Result: Groovy/Grails
Code (5): JRuby
require "rubygems"
require "neo4j"

class Person
    include Neo4j::NodeMixin

      property :name, :salary, :age, :country

      has_n :friends

      index :name, :salary, :age, :country
end

neo = Person.new :name => 'Neo'
morpheus = Person.new :name => 'Morpheus'
neo.friends << morpheus
Neo4j system characteristics
  Disk-based
    Native graph storage engine with custom binary on-disk
    format
  Robust
    6+ years in 24/7 production
  Fast
     1-2 million nodes per second
  Transactional
    JTA/JTS, XA, 2PC, Tx recovery, deadlock detection,
    MVCC, etc
  Scales up
    Many b i l l i on s of nodes/rels/props on single JVM
What do I use this stuff for?
  Modeling, productivity, stability
    Bindings, migrations, robustness
  Fast graph algos on critical path
    Shortest path (Spatial, GIS, Social Web, Routing)
  Fast traversals
     Hierarchies, Networks (Automation, ERP, Intelligence,
     Finance)
     Recommendation engines (social, bioinfo)
     Multidimensional indexes (BI, Analytics, versioning)
     Activity Streams, Write Load -> Read Load
     RDF, SAIL, SemWeb
Query languages
 SPARQL – “SQL for linked data”
    Ex: ”SELECT ?person WHERE {
          ?person neo4j:KNOWS ?friend .
          ?friend neo4j:KNOWS ?foe .
          ?foe neo4j:name “Larry Ellison” .
     }”


 Gremlin – “perl for graphs”
    Ex: ”./outE[@label='KNOWS']/inV[@age   > 30]/@name”
The Neo4j ecosystem
 Neo4j-kernel is an embedded database
   Tiny teeny lil jar f le
                      i
 Component ecosystem
   Index
   REST
   meta-model
   graph-matching
   remote-graphdb
   sparql-engine
   ...
 See http://components.neo4j.org
Example: Neo4j-RDF

         Neo4j-RDF triple/quad store
                    REST

               OWL          SPARQL

        RDF
                  Metamodel       Graph
                                  match



                    Neo4j
Language bindings
 Neo4j.py – bindings for Jython and CPython
    http://components.neo4j.org/neo4j.py
 Neo4jrb – bindings for JRuby (incl RESTful API)
    http://wiki.neo4j.org/content/Ruby
 Clojure
    http://wiki.neo4j.org/content/Clojure
 Scala (incl RESTful API)
    http://wiki.neo4j.org/content/Scala
 PHP
    http://wiki.neo4j.org/content/PHP
 Erlang, Compojure ...
Scale out – replication
  Rolling out Neo4j HA... soon :)
  Master-slave replication, 1st configuration
     MySQL style... ish
     Except all instances can write, synchronously between
     writing slave & master (strong consistency)
     Updates are asynchronously propagated to the other
     slaves (eventual consistency)
  This can handle billions of entities...
  … but not 100B
Scale out – partitioning
  Sharding possible today
     … but you have to do manual work
     … just as with MySQL
     Great option: shard on top of resilient, scalable OSS app
     server               , see: www.codecauldron.org
  Transparent partitioning? Neo4j 2.0
     100B? Easy to say. Sliiiiightly harder to do.
     Fundamentals: BASE & eventual consistency
     Generic clustering algorithm as base case, but give lots of
     knobs for developers
  Cross-shard edges->Node migration/replication->Partition
  schemes
Conclusion
 Graphs && Neo4j => teh awesome!
 Available NOW under AGPLv3 / commercial license
   AGPLv3: “if you’re open source, we’re open source”
   If you have proprietary software? Must buy a commercial
   license
   But the first one is free!
 Download
   http://neo4j.org
 Feedback
   http://lists.neo4j.org
Looking ahead: polyglot persistence


       SQL       &&      N oSQL
Questions?




             Image credit: lost again! Sorry :(
http://neotechnology.com

More Related Content

Similar to Neo4j Nosqllive

Neo4j spatial-nosql-frankfurt
Neo4j spatial-nosql-frankfurtNeo4j spatial-nosql-frankfurt
Neo4j spatial-nosql-frankfurtPeter Neubauer
 
Basic Neo4j Code Examples 2008 05 08
Basic Neo4j Code Examples 2008 05 08Basic Neo4j Code Examples 2008 05 08
Basic Neo4j Code Examples 2008 05 08Dan Nguyen
 
Neo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick assNeo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick assEmil Eifrem
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesPeter Neubauer
 
Geekout Tallinn - Neo4j for the rescue!
Geekout Tallinn - Neo4j for the rescue!Geekout Tallinn - Neo4j for the rescue!
Geekout Tallinn - Neo4j for the rescue!Peter Neubauer
 
Traversing Graph Databases with Gremlin
Traversing Graph Databases with GremlinTraversing Graph Databases with Gremlin
Traversing Graph Databases with GremlinMarko Rodriguez
 
The Path-o-Logical Gremlin
The Path-o-Logical GremlinThe Path-o-Logical Gremlin
The Path-o-Logical GremlinMarko Rodriguez
 
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)Emil Eifrem
 
MARTE Repetitive Structure Modeling
MARTE Repetitive Structure ModelingMARTE Repetitive Structure Modeling
MARTE Repetitive Structure Modelingpboulet
 
The Gremlin in the Graph
The Gremlin in the GraphThe Gremlin in the Graph
The Gremlin in the GraphMarko Rodriguez
 
NOSQL Overview, Neo4j Intro And Production Example (QCon London 2010)
NOSQL Overview, Neo4j Intro And Production Example (QCon London 2010)NOSQL Overview, Neo4j Intro And Production Example (QCon London 2010)
NOSQL Overview, Neo4j Intro And Production Example (QCon London 2010)Emil Eifrem
 

Similar to Neo4j Nosqllive (15)

Eifrem neo4j
Eifrem neo4jEifrem neo4j
Eifrem neo4j
 
Neo4j spatial-nosql-frankfurt
Neo4j spatial-nosql-frankfurtNeo4j spatial-nosql-frankfurt
Neo4j spatial-nosql-frankfurt
 
Basic Neo4j Code Examples 2008 05 08
Basic Neo4j Code Examples 2008 05 08Basic Neo4j Code Examples 2008 05 08
Basic Neo4j Code Examples 2008 05 08
 
Neo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick assNeo4j -- or why graph dbs kick ass
Neo4j -- or why graph dbs kick ass
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examples
 
Neo4j
Neo4jNeo4j
Neo4j
 
Geekout Tallinn - Neo4j for the rescue!
Geekout Tallinn - Neo4j for the rescue!Geekout Tallinn - Neo4j for the rescue!
Geekout Tallinn - Neo4j for the rescue!
 
Traversing Graph Databases with Gremlin
Traversing Graph Databases with GremlinTraversing Graph Databases with Gremlin
Traversing Graph Databases with Gremlin
 
The Path-o-Logical Gremlin
The Path-o-Logical GremlinThe Path-o-Logical Gremlin
The Path-o-Logical Gremlin
 
Gremlin
Gremlin Gremlin
Gremlin
 
Neo4 jv2 english
Neo4 jv2 englishNeo4 jv2 english
Neo4 jv2 english
 
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
A NOSQL Overview And The Benefits Of Graph Databases (nosql east 2009)
 
MARTE Repetitive Structure Modeling
MARTE Repetitive Structure ModelingMARTE Repetitive Structure Modeling
MARTE Repetitive Structure Modeling
 
The Gremlin in the Graph
The Gremlin in the GraphThe Gremlin in the Graph
The Gremlin in the Graph
 
NOSQL Overview, Neo4j Intro And Production Example (QCon London 2010)
NOSQL Overview, Neo4j Intro And Production Example (QCon London 2010)NOSQL Overview, Neo4j Intro And Production Example (QCon London 2010)
NOSQL Overview, Neo4j Intro And Production Example (QCon London 2010)
 

More from Peter Neubauer

2012 09 SF Data Mining zero to hero
2012 09 SF Data Mining zero to hero2012 09 SF Data Mining zero to hero
2012 09 SF Data Mining zero to heroPeter Neubauer
 
Test driven documentation
Test driven documentationTest driven documentation
Test driven documentationPeter 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
 

More from Peter Neubauer (8)

2012 09 SF Data Mining zero to hero
2012 09 SF Data Mining zero to hero2012 09 SF Data Mining zero to hero
2012 09 SF Data Mining zero to hero
 
Test driven documentation
Test driven documentationTest driven documentation
Test driven documentation
 
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.
 

Recently uploaded

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Neo4j Nosqllive

  • 1.
  • 2. No SQL? Image credit: http://browsertoolkit.com/fault-tolerance.png
  • 3. Neo4j the benefits of graph databases #neo4j Peter Neubauer @peterneubauer COO, Neo Technology peter@neotechnology.com
  • 4. Why NoSQL 2009? Trend 1: Size. Trend 2: Connectivity. Trend 3: Semi-structure. Trend 4: Architecture.
  • 5. NOSQL data models Key-value stores Data size Bigtable clones Document databases Graph databases Data complexity
  • 6. NOSQL data models Key-value stores Data size Bigtable clones Document databases Graph databases (This is still b i l l i on s of 90% nodes & relationships) of use cases Data complexity
  • 8. The Graph DB model: representation Core abstractions: name = “Emil” Nodes age = 29 sex = “yes” Relationships between nodes Properties on both 1 2 type = KNOWS time = 4 years 3 type = car vendor = “SAAB” model = “95 Aero”
  • 9. Example: The Matrix name = “The Architect” name = “Morpheus” rank = “Captain” name = “Thomas Anderson” occupation = “Total badass” 42 age = 29 disclosure = public KNOWS KNOWS CODED_BY KNO 1 7 3 W S KN 13 S OW name = “Cypher” KNOW S last name = “Reagan” name = “Agent Smith” disclosure = secret version = 1.0b age = 3 days age = 6 months language = C++ 2 name = “Trinity”
  • 10. Code (1): Building a node space 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
  • 11. Code (1): 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();
  • 12. Code (1b): Def ning RelationshipTypes i // In package org.neo4j.graphdb public interface RelationshipType { String name(); } // In package org.yourdomain.yourapp // Example on how to roll dynamic RelationshipTypes RelationshipsType myRelType = DynamicRelatoinshipType. withName(“myRelType”); // Example on how to kick it, static-RelationshipType-like enum MyStaticRelTypes implements RelationshipType { KNOWS, WORKS_FOR, }
  • 13. Whiteboard friendly owns Björn Big Car build drives DayCare
  • 14.
  • 15. The Graph DB model: traversal Traverser framework for high-performance traversing name = “Emil” age = 31 across the node space sex = “yes” 1 2 type = KNOWS time = 4 years 3 type = car vendor = “SAAB” model = “95 Aero”
  • 16. Example: Mr Anderson’s friends name = “The Architect” name = “Morpheus” rank = “Captain” name = “Thomas Anderson” occupation = “Total badass” 42 age = 29 disclosure = public KNOWS KNOWS CODED_BY KNO 1 7 3 W S KN 13 S OW name = “Cypher” KNOW S last name = “Reagan” name = “Agent Smith” disclosure = secret version = 1.0b age = 3 days age = 6 months language = C++ 2 name = “Trinity”
  • 17. Code (2): Traversing a node space // 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" ) ); }
  • 18. name = “The Architect” name = “Morpheus” rank = “Captain” name = “Thomas Anderson” occupation = “Total badass” 42 age = 29 disclosure = public KNOWS KNOWS CODED_BY KNO 1 7 3 W S KN 13 S OW name = “Cypher” KNOW S last name = “Reagan” name = “Agent Smith” disclosure = secret version = 1.0b age = 3 days age = 6 months language = C++ 2 name = “Trinity” $ bin/start-neo-example Mr Anderson's friends: At depth 1 => Morpheus friendsTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, At depth 1 => Trinity StopEvaluator.END_OF_GRAPH, At depth 2 => Cypher ReturnableEvaluator.ALL_BUT_START_NODE, RelTypes.KNOWS, At depth 3 => Agent Smith Direction.OUTGOING ); $
  • 19. Example: Friends in love? name = “The Architect” name = “Morpheus” rank = “Captain” name = “Thomas Anderson” occupation = “Total badass” 42 age = 29 disclosure = public KNOWS KNOWS CODED_BY KNO 1 7 3 W S KN 13 S KNOW OW name = “Cypher” S last name = “Reagan” name = “Agent Smith” LO disclosure = secret version = 1.0b VE age = 6 months language = C++ S 2 name = “Trinity”
  • 20. Code (3a): Custom traverser // Create a traverser that returns all “friends in love” Traverser loveTraverser = mrAnderson.traverse( Traverser.Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH, new ReturnableEvaluator() { public boolean isReturnableNode( TraversalPosition pos ) { return pos.currentNode().hasRelationship( RelTypes.LOVES, Direction.OUTGOING ); } }, RelTypes.KNOWS, Direction.OUTGOING );
  • 21. Code (3a): Custom traverser // Traverse the node space and print out the result System.out.println( "Who’s a lover?" ); for ( Node person : loveTraverser ) { System.out.printf( "At depth %d => %s%n", loveTraverser.currentPosition().getDepth(), person.getProperty( "name" ) ); }
  • 22. name = “The Architect” name = “Morpheus” rank = “Captain” name = “Thomas Anderson” occupation = “Total badass” 42 age = 29 disclosure = public KNOWS KNOWS KNO CODED_BY 1 7 3 W S KN 13 S name = “Cypher” KNOW OW S last name = “Reagan” name = “Agent Smith” LO disclosure = secret version = 1.0b VE age = 6 months language = C++ S 2 name = “Trinity” $ bin/start-neo-example new ReturnableEvaluator() Who’s a lover? { public boolean isReturnableNode( TraversalPosition pos) At depth 1 => Trinity { $ return pos.currentNode(). hasRelationship( RelTypes.LOVES, Direction.OUTGOING ); } },
  • 23. Domain layer frameworks Spring (SpringDM, Grails, Griffon etc), Sling, Karaf Rails, Django Qi4j (www.qi4j.org) Framework for doing DDD in pure Java5 Def nes Entities / Associations / Properties i Sound familiar? Nodes / Rel’s / Properties! Neo4j is an “EntityStore” backend Jo4neo (http://code.google.com/p/jo4neo) Annotation driven Weaves Neo4j-backed persistence into domain objects at runtime
  • 24. Code (4): Groovy/Grails import grails.plugins.neo4j.* @Neo4jEntity class Author { @Neo4jIndex String name }
  • 26. Code (5): JRuby require "rubygems" require "neo4j" class Person include Neo4j::NodeMixin property :name, :salary, :age, :country has_n :friends index :name, :salary, :age, :country end neo = Person.new :name => 'Neo' morpheus = Person.new :name => 'Morpheus' neo.friends << morpheus
  • 27. Neo4j system characteristics Disk-based Native graph storage engine with custom binary on-disk format Robust 6+ years in 24/7 production Fast 1-2 million nodes per second Transactional JTA/JTS, XA, 2PC, Tx recovery, deadlock detection, MVCC, etc Scales up Many b i l l i on s of nodes/rels/props on single JVM
  • 28. What do I use this stuff for? Modeling, productivity, stability Bindings, migrations, robustness Fast graph algos on critical path Shortest path (Spatial, GIS, Social Web, Routing) Fast traversals Hierarchies, Networks (Automation, ERP, Intelligence, Finance) Recommendation engines (social, bioinfo) Multidimensional indexes (BI, Analytics, versioning) Activity Streams, Write Load -> Read Load RDF, SAIL, SemWeb
  • 29. Query languages SPARQL – “SQL for linked data” Ex: ”SELECT ?person WHERE { ?person neo4j:KNOWS ?friend . ?friend neo4j:KNOWS ?foe . ?foe neo4j:name “Larry Ellison” . }” Gremlin – “perl for graphs” Ex: ”./outE[@label='KNOWS']/inV[@age > 30]/@name”
  • 30. The Neo4j ecosystem Neo4j-kernel is an embedded database Tiny teeny lil jar f le i Component ecosystem Index REST meta-model graph-matching remote-graphdb sparql-engine ... See http://components.neo4j.org
  • 31. Example: Neo4j-RDF Neo4j-RDF triple/quad store REST OWL SPARQL RDF Metamodel Graph match Neo4j
  • 32. Language bindings Neo4j.py – bindings for Jython and CPython http://components.neo4j.org/neo4j.py Neo4jrb – bindings for JRuby (incl RESTful API) http://wiki.neo4j.org/content/Ruby Clojure http://wiki.neo4j.org/content/Clojure Scala (incl RESTful API) http://wiki.neo4j.org/content/Scala PHP http://wiki.neo4j.org/content/PHP Erlang, Compojure ...
  • 33. Scale out – replication Rolling out Neo4j HA... soon :) Master-slave replication, 1st configuration MySQL style... ish Except all instances can write, synchronously between writing slave & master (strong consistency) Updates are asynchronously propagated to the other slaves (eventual consistency) This can handle billions of entities... … but not 100B
  • 34. Scale out – partitioning Sharding possible today … but you have to do manual work … just as with MySQL Great option: shard on top of resilient, scalable OSS app server , see: www.codecauldron.org Transparent partitioning? Neo4j 2.0 100B? Easy to say. Sliiiiightly harder to do. Fundamentals: BASE & eventual consistency Generic clustering algorithm as base case, but give lots of knobs for developers Cross-shard edges->Node migration/replication->Partition schemes
  • 35. Conclusion Graphs && Neo4j => teh awesome! Available NOW under AGPLv3 / commercial license AGPLv3: “if you’re open source, we’re open source” If you have proprietary software? Must buy a commercial license But the first one is free! Download http://neo4j.org Feedback http://lists.neo4j.org
  • 36. Looking ahead: polyglot persistence SQL && N oSQL
  • 37. Questions? Image credit: lost again! Sorry :(