GRAPH DATABASES
Girish Jayappa
Social Network Example Facebook , LinkedIn etc
Network - LAN,WAN etc
Maps/Route finder - ex Google Maps
Recommendations ex Flipkart, Amazon, IMDB,Facebook, LinkedIn etc
A GRAPH
GRAPH DATA MODEL
NODES
RELATIONSHIPS
RELATIONSHIPS (CONTINUED)
LABELS
WHITEBOARD FRIENDLINESS
Direct representation of the model ( Easy to design and model )
REFINED DATA MODEL
RDBMS V/S GRAPH DATABASE
SOCIAL NETWORK PATH EXISTS
PERFORMANCE
Experiment:
~1000 persons
Average 50 friends per person
pathExists(a,b) limited to depth 4
IF YOUVE EVER
Joined more than 7 tables together
Modeled a graph in a table
Tried to write some crazy stored procedure with multiple recursive self and
inner joins
Lot of semi-structured data
You should use a graph database ( ex
Neo4j)
NEO4J IS A GRAPH DATABASE
a schema-free labeled Property Graph
perfect for complex, highly connected data
reliable with real ACID Transactions
scalable: Billions of Nodes and Relationships, Scale out with highly available
Neo4j-Cluster
32 Billion Nodes, 32 Billion Relationships, 64 Billion Properties
fast with more than 2M traversals / second
Embedded Server with REST API
Query Language - Cypher
CYPHER SOME SYNTAX
Create nodes with relationships
create (ad:Actor{name:"Ajay Devgan",gender:"male"}),
(ak:Actor{name:"Akshay Kumar",gender:"male",location:"Punjab"}),
(srk:Actor{name:"Shahrukh Khan',gender:"male"}),
(sk:Actor{name:"Salman Khan",gender:"male"}),
(ad)-[:FRIEND]->(ak),(ak)-[:FRIEND]->(srk),(srk)-[:FRIEND]->(sk)
MATCH nodes and create relationships
MATCH (ad:Actor { name: 'Ajay Devgan' }), (sk:Actor { name: 'Salman Khan' })
CREATE (ad)-[:FRIEND]->(sk)
REAL TIME SEARCH/RECOMMENDATION EXAMPLE
SMALL DEMO
1. Find Shortest path between 2 people
2. RESTful ready