drupal and neo4j

56
Drupal & Graphs

Upload: peter-arato

Post on 27-Jan-2015

136 views

Category:

Technology


0 download

DESCRIPTION

Graph databases and a use case with Drupal.

TRANSCRIPT

Page 1: Drupal and Neo4J

Drupal & Graphs

Page 2: Drupal and Neo4J
Page 3: Drupal and Neo4J

• The “problem”

• Graph databases

• Neo4J

• Examples

• Drupal & graph

• Future

Page 4: Drupal and Neo4J

The problem

Page 5: Drupal and Neo4J

too many joins

Page 6: Drupal and Neo4J

query is unknown

Page 7: Drupal and Neo4J

tricks only graphs can solve

Page 8: Drupal and Neo4J

1M nodes, ~50 rel/nodeDepth RDBMS Neo4J Returned

records

2 0.016 0.01 ~2’500

3 30.267 0.168 ~110’000

4 1543.505 1.359 ~600’000

5 unfinished 2.132 ~800’000

Page 9: Drupal and Neo4J

Such speed

So wow

Very graph

Page 10: Drupal and Neo4J

Examples

Page 11: Drupal and Neo4J
Page 12: Drupal and Neo4J

• Business Intelligence

• Content Management

• Fraud Detection

• Geo

• Graph Search

• Identity & Access Management

• Impact Analysis

• Logistics

• Master Data Management

• Network and Data Center Management

• Product Catalog

• Recommendation Engine

• Resource Authorization & Access Control

• Social Network

Page 13: Drupal and Neo4J

http://gist.neo4j.org/

Page 14: Drupal and Neo4J

Graph databases

Page 15: Drupal and Neo4J

Node NodeRelationship

Page 16: Drupal and Neo4J

Jim Lisa:COOK_FOR

Page 17: Drupal and Neo4J

Jim:PERSON Lisa:PERSON

:COOK_FOR

city: London gender: male

city: San Francisco gender: female

meal: Jalfrezi score: 9.8

user_index::uid::3 user_index::uid::8

Page 18: Drupal and Neo4J

Jim:PERSON Lisa:PERSON

:COOK_FOR

city: London gender: male

city: San Francisco gender: female

meal: Jalfrezi score: 9.8

:LOVE

user_index::uid::3 user_index::uid::8

Page 19: Drupal and Neo4J

hop

hop

hop

?

N hops

Page 20: Drupal and Neo4J

Start

Page 21: Drupal and Neo4J
Page 22: Drupal and Neo4J

designing graph db

Page 23: Drupal and Neo4J

John

Visit

Paris

Eiffel Louvre

VisitVisit

Page 24: Drupal and Neo4J

John

Visit

Paris

Eiffel Louvre

HasHas

Page 25: Drupal and Neo4J

John

Attended

ParisEiffel Louvre

Include

Travel

IncludeCity

Page 26: Drupal and Neo4J

1973

Jan JuneMarch

12 245

1986

3 11

Page 27: Drupal and Neo4J

Node

Term

Italy

Node!{t:Italy} vs

:HAS_TERM

:TERM_NAME

Page 28: Drupal and Neo4J
Page 29: Drupal and Neo4J
Page 30: Drupal and Neo4J
Page 31: Drupal and Neo4J

Neo4J

Page 32: Drupal and Neo4J

Server: embedded - server mode

low latency network

low level API REST API

better control better scaling

JVM only languages

Page 33: Drupal and Neo4J

Backend

Page 34: Drupal and Neo4J

db

labels nodes

propsrels

Page 35: Drupal and Neo4J

Node

inUse nextRelId nextPropId

Page 36: Drupal and Neo4J

Relationship

inUse

firstNode

secondNode

relType

firstPrevRelId

firstNextRelId

secondPrevRelId

secondNextRelId

nextPropId

Page 37: Drupal and Neo4J

Disks

Record files

File system cache

Object cache

Traversal API Cypher

Transaction log

Transaction management

Core API

Page 38: Drupal and Neo4J

Core API

Page 39: Drupal and Neo4J

Traversal API

Page 40: Drupal and Neo4J

Cypher

Page 41: Drupal and Neo4J

MATCH (n)-[r]->(m)

Page 42: Drupal and Neo4J

• MATCH (n)-[r]->(m) • MATCH (n:USER)-[:EAT]->(m:FOOD) • MATCH p = (n)--(m) • MATCH (n{name:’Jim’})-[r]->(m) • MATCH (o)-->(n)<-[*1..3]-(m) • MATCH [:TRAVEL{by:”bus”}]->(n)

Page 43: Drupal and Neo4J

START n=node(*)

Page 44: Drupal and Neo4J

• START n=node(12) • START n=node({12, 3, 7}) • START n=node:user_index(uid=“12”) • START n=node(3), m=node(12)

Page 45: Drupal and Neo4J

• WHERE n.name = ‘Jim’ • WHERE n.has(“name”) • WITH count(n) AS all WHERE all > 10

Page 46: Drupal and Neo4J

• RETURN n • RETURN collect(n), o.name • RETURN length(p)

Page 47: Drupal and Neo4J

I want a good party this Friday. Show me my foaf who has at least 20 close

friends - so I can avoid awkward parties. And they don’t know my ex.

Page 48: Drupal and Neo4J

START n=node(12) MATCH p = (n)-[:FRIEND*]->(m), (m)<-[:FRIEND*1..2]-(o) WHERE any(p IN collect(o) WHERE p.name != ‘Liz’) WITH count(o) AS total WHERE total >= 20 RETURN m.name, p, total, collect(o)

Page 49: Drupal and Neo4J

CREATE (jim:USER{hair:’green’}), (erica:USER{hair:’brown’}), jim-[:REPORTS_TO{type:’TPS’}]->erica; !

MATCH (n) SET n.name = ‘Walter’; !

MATCH (n) DELETE n;

Page 50: Drupal and Neo4J

Drupal <3 Neo4J

Page 51: Drupal and Neo4J

https://drupal.org/project/neo4j_connector

Page 52: Drupal and Neo4J

Neo4JNeo4J-PHPNeo4J!Drupal!

Connector

REST API

Page 53: Drupal and Neo4J

• Pluggable indexes

• Dynamic labels, properties and relationships

• “smart” indexing

Page 54: Drupal and Neo4J

DEMO

Page 55: Drupal and Neo4J

Future?

• Cypher builder

• Views integration

• More field support

• Embedded graph display

Page 56: Drupal and Neo4J

Thank You

Questions?