Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Graph Databases
A little connected tour
Francisco Fernández Castaño
!
@fcofdezc
Beginning
The old town of Königsberg has seven bridges:
Can you take a walk through town, visiting each part of
the town and crossin...
El origenG = (V, E)
What is a Graph DB?
Graph
Nodes Relationships
Properties
Store
Store
Connect
Have
Have
Written in Java
ACID
Rest interface
Cypher
Why Graph DB?
The traditional way in the context
of connected data is artificial
!Scalability
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 Acab...
Person
Id Person
1 Frank
2 John
.. …
99 Alice
PersonFriend
PersonID FriendID
1 2
2 1
.. …
99 2
O(log n)
O(1)
O(m log n)
O(m)
We can transform our domain model in a
natural way
Use cases
Social Networks
Follow
Follow
John Jeff
Douglas
Geospatial problems
Fraud detection
Authorization
Network management
Recommendation
System
Cypher
Declarative language
ASCII oriented
Pattern matching
Cypher
Cypher
Traverser API
Core API
Kernel
Cypher
a b
(a)-->(b)
Cypher
clapton cream
(clapton)-[:play_in]->(cream)
play_in
Follow
FollowJohn Jeff
Douglas
Cypher
(john:User)-[:FOLLOW]->(jeff:User)	
!
(douglas:User)-[:FOLLOW]->(john:User)
Cypher
clapton
{name: Eric
Clapton}
cream
(clapton)-[:play_in]->(cream)<-[:labeled]-(blues)
play_in
{date: 1968}
Blues
lab...
Cypher
MATCH (m)-[:PLAY_IN]—>(b)	
RETURN m,b;
Cypher
MATCH (m)-[:PLAY_IN]—>(b),	
	 	 (b)<-[:LABELED]-(s)	
RETURN m.name,	
	 	 	 t.date,	
	 	 	 s.name;
Cypher
MATCH (c {name: ‘clapton’})-[t:PLAY_IN]—>(b),	
	 (b)<-[:LABELED]-(s)	
RETURN c.name,	
	 	 b.name,	
	 	 s.name;
Cypher
MATCH (c {name: ‘clapton’})-[t:PLAY_IN]—>(b),	
	 (b)<-[:LABELED]-(e {name: ‘blues’})	
RETURN c.name,	
	 	 b.name,	
...
Cypher
MATCH (c {name: ‘clapton’})-[r:PLAY_IN | PRODUCE]—>(b),	
	 (b)<-[:LABELED]-(e {name: ‘blues’})	
RETURN c.name,	
	 b...
Cypher
MATCH (a)-[:KNOW*5]—>(b)
MATCH p = (startNode:Station {name: ‘Sol’})	
	 -[rels:CONNECTED_TO*]->	
(endNode:Station {name: ‘Retiro’})	
RETURN p AS sh...
Neo4J extensions
Managed
Unmanaged
Neo4J extensions
Managed
Unmanaged
Neo4J extensions
Managed
Unmanaged
Drivers/Clients
Instead of just picking a relational database
because everyone does, we need to
understand the nature of the data we’re
st...
References
Neo4J as a service
http://www.graphenedb.com
Danke
Graph databases - EuroPython 2014
Graph databases - EuroPython 2014
Graph databases - EuroPython 2014
Graph databases - EuroPython 2014
Nächste SlideShare
Wird geladen in …5
×

Graph databases - EuroPython 2014

1.693 Aufrufe

Veröffentlicht am

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/

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

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

×