42
Neo4j Tabriz Software Open Talks #opentalks @silverman2OOO9 2015-10-29 / 1394-08-07 Farzin Bagheri

introduction to Neo4j (Tabriz Software Open Talks)

Embed Size (px)

Citation preview

Neo4j

Tabriz Software Open Talks

#opentalks

@silverman2OOO9

2015-10-29 / 1394-08-07

Farzin Bagheri

Table of Contents

Database

Relational Databases

NOSQL

● NOSQL Categories

Neo4j● Cypher● Example● Usage

Database

Relational Database

● Relational Database : SQL Server , MySQL , Oracle,...● Concepts : Table , Row, Column,…

But,is it enough?

No !

Why?

● Cost● Need Powerful hardware● Need Expert● Sometimes we need only some feature

NoSQL Databases

What is NoSQL ?

NoSQL

Not Only SQL

4 Type of NoSQL Databases :

● Key-Value : ○ Data mode : Key and value! for example : Set A 20○ Example : Redis , Riak , Dynamodb (Amazon) ,...○ Use Case : Task Queue (Celery) , Cashing ,...

● Document : ○ Data model : collection of Key - value : { FName : “Farzin” , LName : ”Bagheri” , City : “Khoy” }

○ Example : MongoDB , couchDB○ Use Case : Inserting a Log Record (Nginx or Apache)

● Column Family or BigTable : ○ Data model : big table! each rows has their own Schema.○ Example : Hbase , Cassandra○ Use Case : like Relational Databases but more flexible

● Graph Databases ○ Data mode : Node (Vertices) , Relationship (Edge) and Properties○ Example : Neo4j , OrientDB , ArangoDB ,... ○ Use Case : Social network , Recommendation , Graph-Based Search,...

4 Type of NoSQL Databases :

● Key-Value : ○ Data mode : Key and value! for example : Set A 20○ Example : Redis , Riak , Dynamodb (Amazon) ,...○ Use Case : Task Queue (Celery) , Cashing ,...

● Document : ○ Data model : collection of Key - value : { FName : “Farzin” , LName : ”Bagheri” , City : “Khoy” }

○ Example : MongoDB , couchDB○ Use Case : Inserting a Log Record (Nginx or Apache)

● Column Family or BigTable : ○ Data model : big table! each rows has their own Schema.○ Example : Hbase , Cassandra○ Use Case : like Relational Databases but more flexible

● Graph Databases ○ Data mode : Node (Vertices) , Relationship (Edge) and Properties○ Example : Neo4j , OrientDB , ArangoDB ,... ○ Use Case : Social network , Recommendation , Graph-Based Search,...

4 Type of NoSQL Databases :

● Key-Value : ○ Data mode : Key and value! for example : Set A 20○ Example : Redis , Riak , Dynamodb (Amazon) ,...○ Use Case : Task Queue (Celery) , Cashing ,...

● Document : ○ Data model : collection of Key - value : { FName : “Farzin” , LName : ”Bagheri” , City : “Khoy” }

○ Example : MongoDB , couchDB○ Use Case : Inserting a Log Record (Nginx or Apache)

● Column Family or BigTable : ○ Data model : big table! each rows has their own Schema.○ Example : Hbase , Cassandra○ Use Case : like Relational Databases but more flexible

● Graph Databases○ Data mode : Node (Vertices) , Relationship (Edge) and Properties○ Example : Neo4j , OrientDB , ArangoDB ,... ○ Use Case : Social network , Recommendation , Graph-Based Search,...

4 Type of NoSQL Databases :

● Key-Value : ○ Data mode : Key and value! for example : Set A 20○ Example : Redis , Riak , Dynamodb (Amazon) ,...○ Use Case : Task Queue (Celery) , Cashing ,...

● Document : ○ Data model : collection of Key - value : { FName : “Farzin” , LName : ”Bagheri” , City : “Khoy” }

○ Example : MongoDB , couchDB○ Use Case : Inserting a Log Record (Nginx or Apache)

● Column Family or BigTable : ○ Data model : big table! each rows has their own Schema.○ Example : Hbase , Cassandra○ Use Case : like Relational Databases but more flexible

● Graph Databases○ Data mode : Node (Vertices) , Relationship (Edge) and Properties○ Example : Neo4j , OrientDB , ArangoDB ,... ○ Use Case : Social network , Recommendation , Graph-Based Search,...

Graph are everywhere

Graph

● Nodes● Relationships● Properties

http://neo4j.com/developer/graph-database/

How to talk to Neo4j?

Cypher

Cypher

Creating Node

Getting

CREATE ( : Person { Fname : "Farzin" , Lname : "Bagheri" } )

Creating other Nodes

CREATE ( :Person { Fname : "Arash" , Lname : "Milani" } ) ,

( :Person { Fname : "Masoud" , Lname : "Sadri" } )

Getting All

Going to be Social ! :)

Creating Relationship :

Small Social Network :

Finding Friend and Friend of Friend :

● Friend of Someone :

Finding Friend and Friend of Friend :

● Friend of Friend of Someone :

● Other way :

Finding All :

Cloud

(app) -[:depend_on]-> (os) - [:depend_on] -> (VM) -[:depend_on] >(Server)-[::depend_on] -> (Power)

Dependency Chain :

Which Server Host App1?

App1 Dependency :

Most Dependent :

Recommendation

MATCH ( p:person { name:"B" } ) -[ :Has ]-> ( o1:Order )-[ :include ]->( b:Book )

<-[ :include ] - ( o2:Order )

-[:include]-> ( otherBook )

where not o1-[:include]->(otherBook)

return distinct ( otherBook.name)

Performance

Usage

● Social network● Network Analysis● Recommendation systems● Fraud Detection

● Path Finding (Shortest path , simple path ,...)● Digital Marketing

Database Popularity Change

Neo4j in Iran & World

Thank you

References

● www.db-engines.com● www.neo4j.com● www.linkedin.com● Graph Database , Ian Robinson , Jim Webber & Emil Eifrem