Graph databases - EuroPython 2014

1,054
-1

Published on

There are many kinds of NoSQL databases like, document databases, key-value, column databases and graph databases. In some scenarios is more convenient to store our data as a graph, because we want to extract and study information relative to these connections. In this scenario, graph databases are the ideal, they are designed and implemented to deal with connected information in a efficient way.
https://ep2014.europython.eu/en/schedule/sessions/70/

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,054
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Graph databases - EuroPython 2014

  1. 1. Graph Databases A little connected tour Francisco Fernández Castaño ! @fcofdezc
  2. 2. Beginning
  3. 3. The old town of Königsberg has seven bridges: Can you take a walk through town, visiting each part of the town and crossing each bridge only once?
  4. 4. El origenG = (V, E)
  5. 5. What is a Graph DB?
  6. 6. Graph Nodes Relationships Properties Store Store Connect Have Have
  7. 7. Written in Java ACID Rest interface Cypher
  8. 8. Why Graph DB?
  9. 9. The traditional way in the context of connected data is artificial
  10. 10. !Scalability
  11. 11. Depth MySQL time (s) Neo4j time (s) Results 2 0.016 0.01 ~2500 3 30.267 0.168 ~110,000 4 1543.505 1.359 ~600,000 5 No Acaba 2.132 ~800,000 MySQL vs Neo4j * Neo4J in Action
  12. 12. Person Id Person 1 Frank 2 John .. … 99 Alice PersonFriend PersonID FriendID 1 2 2 1 .. … 99 2
  13. 13. O(log n)
  14. 14. O(1)
  15. 15. O(m log n)
  16. 16. O(m)
  17. 17. We can transform our domain model in a natural way
  18. 18. Use cases
  19. 19. Social Networks Follow Follow John Jeff Douglas
  20. 20. Geospatial problems Fraud detection Authorization Network management
  21. 21. Recommendation System
  22. 22. Cypher Declarative language ASCII oriented Pattern matching
  23. 23. Cypher Cypher Traverser API Core API Kernel
  24. 24. Cypher a b (a)-->(b)
  25. 25. Cypher clapton cream (clapton)-[:play_in]->(cream) play_in
  26. 26. Follow FollowJohn Jeff Douglas Cypher (john:User)-[:FOLLOW]->(jeff:User) ! (douglas:User)-[:FOLLOW]->(john:User)
  27. 27. Cypher clapton {name: Eric Clapton} cream (clapton)-[:play_in]->(cream)<-[:labeled]-(blues) play_in {date: 1968} Blues labeled
  28. 28. Cypher MATCH (m)-[:PLAY_IN]—>(b) RETURN m,b;
  29. 29. Cypher MATCH (m)-[:PLAY_IN]—>(b), (b)<-[:LABELED]-(s) RETURN m.name, t.date, s.name;
  30. 30. Cypher MATCH (c {name: ‘clapton’})-[t:PLAY_IN]—>(b), (b)<-[:LABELED]-(s) RETURN c.name, b.name, s.name;
  31. 31. Cypher MATCH (c {name: ‘clapton’})-[t:PLAY_IN]—>(b), (b)<-[:LABELED]-(e {name: ‘blues’}) RETURN c.name, b.name, e.name ORDER BY t.date
  32. 32. Cypher MATCH (c {name: ‘clapton’})-[r:PLAY_IN | PRODUCE]—>(b), (b)<-[:LABELED]-(e {name: ‘blues’}) RETURN c.name, b.name, e.name WHERE r.date > 1968 ORDER BY r.date
  33. 33. Cypher MATCH (a)-[:KNOW*5]—>(b)
  34. 34. MATCH p = (startNode:Station {name: ‘Sol’}) -[rels:CONNECTED_TO*]-> (endNode:Station {name: ‘Retiro’}) RETURN p AS shortestPath, reduce(weight=0, r in rels: weight + r.weight) as tWeight ORDER BY tWeight ASC LIMIT 1
  35. 35. Neo4J extensions Managed Unmanaged
  36. 36. Neo4J extensions Managed Unmanaged
  37. 37. Neo4J extensions Managed Unmanaged
  38. 38. Drivers/Clients
  39. 39. Instead of just picking a relational database because everyone does, we need to understand the nature of the data we’re storing and how we want to manipulate it. Martin Fowler
  40. 40. References
  41. 41. Neo4J as a service http://www.graphenedb.com
  42. 42. Danke

×