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/node
Depth RDBMS Neo4J
Returned
records
2 0.016 0.01 ~2’500
3 30.267 0.168 ~110’000
4 1543.505 1.359 ~60...
Such speed
So wow
Very graph
Examples
• Business Intelligence
• Content Management
• Fraud Detection
• Geo
• Graph Search
• Identity & Access
Management
• Impac...
http://gist.neo4j.org/
Graph databases
Node Node
Relationship
Jim Lisa
:COOK_FOR
Jim:PERSON Lisa:PERSON
:COOK_FOR
city: London
gender: male
city: San Francisco
gender: female
meal: Jalfrezi
score: 9.8
us...
Jim:PERSON Lisa:PERSON
:COOK_FOR
city: London
gender: male
city: San Francisco
gender: female
meal: Jalfrezi
score: 9.8
:L...
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
Include
City
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)--...
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 t...
START n=node(12)
MATCH
p = (n)-[:FRIEND*]->(m),
(m)<-[:FRIEND*1..2]-(o)
WHERE
any(p IN collect(o) WHERE p.name != ‘Liz’)
W...
CREATE
(jim:USER{hair:’green’}),
(erica:USER{hair:’brown’}),
jim-[:REPORTS_TO{type:’TPS’}]->erica;
!
MATCH (n) SET n.name ...
Drupal <3 Neo4J
https://drupal.org/
project/neo4j_connector
Neo4JNeo4J-PHP
Neo4J!
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?
Drupal and Neo4J
Drupal and Neo4J
Drupal and Neo4J
Drupal and Neo4J
Drupal and Neo4J
Drupal and Neo4J
Prochain SlideShare
Chargement dans…5
×

Drupal and Neo4J

5 807 vues

Publié le

Graph databases and a use case with Drupal.

Publié dans : Technologie
0 commentaire
3 j’aime
Statistiques
Remarques
  • Soyez le premier à commenter

Aucun téléchargement
Vues
Nombre de vues
5 807
Sur SlideShare
0
Issues des intégrations
0
Intégrations
47
Actions
Partages
0
Téléchargements
10
Commentaires
0
J’aime
3
Intégrations 0
Aucune incorporation

Aucune remarque pour cette diapositive

Drupal and Neo4J

  1. 1. Drupal & Graphs
  2. 2. • The “problem” • Graph databases • Neo4J • Examples • Drupal & graph • Future
  3. 3. The problem
  4. 4. too many joins
  5. 5. query is unknown
  6. 6. tricks only graphs can solve
  7. 7. 1M nodes, ~50 rel/node Depth 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
  8. 8. Such speed So wow Very graph
  9. 9. Examples
  10. 10. • 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
  11. 11. http://gist.neo4j.org/
  12. 12. Graph databases
  13. 13. Node Node Relationship
  14. 14. Jim Lisa :COOK_FOR
  15. 15. 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
  16. 16. 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
  17. 17. hop hop hop ? N hops
  18. 18. Start
  19. 19. designing graph db
  20. 20. John Visit Paris Eiffel Louvre VisitVisit
  21. 21. John Visit Paris Eiffel Louvre HasHas
  22. 22. John Attended ParisEiffel Louvre Include Travel Include City
  23. 23. 1973 Jan JuneMarch 12 245 1986 3 11
  24. 24. Node Term Italy Node! {t:Italy} vs :HAS_TERM :TERM_NAME
  25. 25. Neo4J
  26. 26. Server: embedded - server mode low latency network low level API REST API better control better scaling JVM only languages
  27. 27. Backend
  28. 28. db labels nodes propsrels
  29. 29. Node inUse nextRelId nextPropId
  30. 30. Relationship inUse firstNode secondNode relType firstPrevRelId firstNextRelId secondPrevRelId secondNextRelId nextPropId
  31. 31. Disks Record files File system cache Object cache Traversal API Cypher Transaction log Transaction management Core API
  32. 32. Core API
  33. 33. Traversal API
  34. 34. Cypher
  35. 35. MATCH (n)-[r]->(m)
  36. 36. • 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)
  37. 37. START n=node(*)
  38. 38. • START n=node(12) • START n=node({12, 3, 7}) • START n=node:user_index(uid=“12”) • START n=node(3), m=node(12)
  39. 39. • WHERE n.name = ‘Jim’ • WHERE n.has(“name”) • WITH count(n) AS all WHERE all > 10
  40. 40. • RETURN n • RETURN collect(n), o.name • RETURN length(p)
  41. 41. 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.
  42. 42. 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)
  43. 43. 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;
  44. 44. Drupal <3 Neo4J
  45. 45. https://drupal.org/ project/neo4j_connector
  46. 46. Neo4JNeo4J-PHP Neo4J! Drupal! Connector REST API
  47. 47. • Pluggable indexes • Dynamic labels, properties and relationships • “smart” indexing
  48. 48. DEMO
  49. 49. Future? • Cypher builder • Views integration • More field support • Embedded graph display
  50. 50. Thank You Questions?

×