Graph Databases 101


Published on

Graph Databases 101 with Neo4J and Friends

Published in: Technology

Graph Databases 101

  1. 1. Graph DB 101 with Neo4j and friends ! Paulo Traça
  2. 2. The Problem
  3. 3. RDBMS are good at Aggregation Ordered data Truly tabular data Few or clearly defined relationships
  4. 4. Relational databases aren’t very good with relationships.
  5. 5. Graph DB’s
  6. 6. A graph database uses graph structure with nodes, edges, and properties to represent and store data. ! By definition, a graph database is any storage system that provides index-free adjacency. This means that every element contains a direct pointer to its adjacent element and no index lookups are necessary.
  7. 7. NODES Nodes represent Entities such as people, businesses, accounts, or any other item you might want to keep track of.
  8. 8. Properties Properties are pertinent information that relate to nodes.
  9. 9. EDGES Edges are the lines that connect nodes to nodes or nodes to properties and they represent the relationship between the two. Most of the important information is really stored in the edges. Meaningful patterns emerge when one examines the connections and interconnections of nodes, properties, and edges.
  10. 10. Graph databases focus on the interconnection between Entities
  11. 11. Compared with relational databases Graph databases are often faster for associative data sets ! map more directly to the structure of object-oriented applications ! Scale more naturally to large data sets as they do not typically require expensive join operations. ! As they depend less on a rigid schema, they are more suitable to manage ad-hoc and changing data with evolving schemas.
  12. 12. What to find vs How to find // Find all the directors who have directed a movie scored by John Williams // that starred Kevin Bacon ! START actor=(actors, 'Kevin Bacon'), composer=(compsers, 'John Williams') MATCH (actor)-[:IN]->(movie)<-[:DIRECTED]-(director),       (movie)<-[:SCORED]-(composer) RETURN director
  13. 13. Modelling a Domain with Graphs Graphs are "whiteboard-friendly" Nouns become nodes Verbs become relationships Properties are adjectives and adverbs
  14. 14. NEO4J
  15. 15. Key Features Java Based Property Graph Model Uses Lucene for indexing of graph/relationship properties ACID Transactions Massive scalability Extensible High performance on deep transversal
  16. 16. Key Features Property Graph Model ! . Nodes . Nodes have key / value properties . Relationships between nodes . Relationships have labels . Relationships have key / value properties . Relationships are directed but transversal at equals speed in both directions . Semantics of the directions is up to the applications
  17. 17. Key Features ACID Transactions Custom JTA/JTS compliant transaction manager distributed transactions two-phase commit (2PC) Transaction recovery deadlock detection ! Massive Scalability Supporting billions of nodes/relationships props on a single machine
  18. 18. Key Features .Can run embedded or Standalone via REST . Plugins : Spatial data, Lucene, RDF, SOLR . Runs on major platforms : Mac | Windows | Unix . Extensive documentation . Active community . Open Source
  19. 19. Enterprise strength database
  20. 20. Finding Stuff
  22. 22. CYPHER Cypher is a declarative graph query language that allows for expressive and efficient querying and updating of the graph store without having to write traversals through the graph structure in code
  23. 23. CYPHER START: Starting points in the graph, obtained via index lookups or by element IDs. MATCH: The graph pattern to match, bound to the starting points in START. WHERE: Filtering criteria. RETURN: What to return. CREATE: Creates nodes and relationships. DELETE: Removes nodes, relationships and properties. SET: Set values to properties. FOREACH: Performs updating actions once per element in a list. WITH: Divides a query into multiple, distinct parts.
  24. 24. Graph Algorithms Shortest paths, all paths, all simple paths, Dijkstra and A*.
  25. 25. REST API
  26. 26. DEMO TIME
  27. 27. That’s All Folks Thank you! ! ! @ptraca
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.