drupal and neo4j

Post on 27-Jan-2015

136 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Graph databases and a use case with Drupal.

TRANSCRIPT

Drupal & Graphs

• The “problem”

• Graph databases

• Neo4J

• Examples

• Drupal & graph

• Future

The problem

too many joins

query is unknown

tricks only graphs can solve

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

Such speed

So wow

Very graph

Examples

• 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

http://gist.neo4j.org/

Graph databases

Node NodeRelationship

Jim Lisa:COOK_FOR

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

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

hop

hop

hop

?

N hops

Start

designing graph db

John

Visit

Paris

Eiffel Louvre

VisitVisit

John

Visit

Paris

Eiffel Louvre

HasHas

John

Attended

ParisEiffel Louvre

Include

Travel

IncludeCity

1973

Jan JuneMarch

12 245

1986

3 11

Node

Term

Italy

Node!{t:Italy} vs

:HAS_TERM

:TERM_NAME

Neo4J

Server: embedded - server mode

low latency network

low level API REST API

better control better scaling

JVM only languages

Backend

db

labels nodes

propsrels

Node

inUse nextRelId nextPropId

Relationship

inUse

firstNode

secondNode

relType

firstPrevRelId

firstNextRelId

secondPrevRelId

secondNextRelId

nextPropId

Disks

Record files

File system cache

Object cache

Traversal API Cypher

Transaction log

Transaction management

Core API

Core API

Traversal API

Cypher

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

• 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)

START n=node(*)

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

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

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

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.

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)

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;

Drupal <3 Neo4J

https://drupal.org/project/neo4j_connector

Neo4JNeo4J-PHPNeo4J!Drupal!

Connector

REST API

• Pluggable indexes

• Dynamic labels, properties and relationships

• “smart” indexing

DEMO

Future?

• Cypher builder

• Views integration

• More field support

• Embedded graph display

Thank You

Questions?

top related