Build Facebook Like
   Relationships
     with Neo4j

             by Von Stark
Von Stark
I am : Starter, Programmer ,Backpacker

Use : Ruby, Rails, Erlang, Neo4j

  co-founder at meetcliv.com

  founder at neo4j.tw

  Engineer at Roodo tech

  co-founder at theprosbank.com

  co-founder at envionow.com

  Sales at 365biotech
4 W & 1 H


What   Why     Who   When


         How
What is Neo4j

Java & Lucene - NeoTechnology

Embedded Document

High Availability & FailOver.

A(atomicity) C(consistency) I(isolation) D(durability)

           Graph Database
What can it do?

Social Network

Graph Network

Complex Relationships

Make database like natural
What is the difference as
    Object Oriented DB



Data preset as Node & Edge   (Objects)

More functions to traverse

Friendly API

Schema = set of Class   (Independent)
Why to use graph - Web3.0




  1999   2000   2010   2020
Why to use Graph - Complexity
Why to use Graph - Whiteboard Friendly
Why to use Graph - Whiteboard Friendly
Why to use graph - Reasons



         (      )

        ->      ,   ->

SQL

 SQL         Join
Who use graph
When to use graph




      Graph

SQL      Key/Vale   NoSQL
When to use graph




      Graph

SQL      Key/Vale   NoSQL
How is the performance
Interested?
Connect
Ruby / Python / Clojure / PHP /
Java / Scala / Erlang / Groovy /
Restful ....

Rails / Grails / Griffon / Qi4j /
Roo...
Clients

PHP - Thrift / Protobuffers / PHP-
Java Bridge

Ruby - JRuby + Neo4j.rb

Python - JPython / CPython + JCC /
Neo4j.py
Some Examples
Remember It
        Relationship

Node                   Node
Remember It
        Relationship

Node                   Node


        Relationship


Node                   Node
Remember It
        Relationship

Node                   Node


        Relationship


Node                   Node
Relationship - FoF - 1 level




              Me




me.outgoing(:friends).depth(1)
Relationship - FoF - 2 level




              Me




me.outgoing(:friends).depth(2)
Relationship - FoF - 3 level




              Me




me.outgoing(:friends).depth(3)
Relationship - FoF - n level




me.outgoing(:friends).depth(n)
Filters
filter / prune



Evaluator -

     INCLUDE_AND_CONTINUE
     INCLUDE_AND_PRUNE
     EXCLUDE_AND_DISCONTINUE
     EXCLUDE_AND_CONTINUE
Complex Example
  FoF who lives in Taipei also like Jazz




        Taipei
                 Jazz
                              Me
Lives
 Like
Friend
Complex Example
  FoF who lives in Taipei also like Jazz




        Taipei
                 Jazz
                              Me
Lives
 Like
Friend
SQL
 ?&^@#%$@)JOIN *&@^ JOIN *@^$ JOIN &@&#
 JOIN (*@#^ JOIN !&@ JOIN


Neo4j
me.outgoing(:friend).depth(:all).filter{|path_to_m|
     path_to_m.end_node.outgoing(:lives).filter{|path_to_live|
       path_to_live==”Taipei”
     }.outgoing(:like).filter{|path_to_like|
        path_to_live==”Jazz”
     }
}
BranchSelector

preorderDepthFirst -      ,

postorderDepthFirst -         ,

preorderBreadthFirst -            ,

postorderBreadthFirst -               ,
Other CRUD

Batch Insertion

Range Query

Compound Query

Uniqueness

Expand

                  and more...
Caching


  File Buffer Cache



  Object Cache
5~10 times faster as file cache for read
Memory eater
Scale - 1
Scale - 2
Web-Admin
Dashboard

                   Console




Data Browser
Visual Tools
NeoClipse    Flare    Dracula




Arbor.js




                          more...
Other Graph DB
Dex

OrientDB

VertexDB

Pregel - Very Mystery

Allegro - Performance just fine

FlockDB - One Layer, Based on MySQL

InfiniteGraph
NoSQL

1




    NoSQL

     ,       ,   ,   ...
,
,
,

Marketing
Angel Investor
Backend Engineer
Q & A

Blog : vonstark.co

FB : facebook.com/vonstark

Twitter : vonstark32

Contact : von@vonstark.co

Neo4j