$30 off During Our Annual Pro Sale. View Details »

Graph Databases: Solving Problems with Connected Data

Graph Databases: Solving Problems with Connected Data

In this connected world, traditional data stores often make it difficult to find valuable relationships. Graph databases focus not only on the entities, but the connections between them. By making relationships a key component of the model, contextualizing a set of data becomes incredibly simple. Join us in this session to learn how graph databases are used to improve the data world and help developers easily make sense of connected data!

Topics:
* Exploring graphs and how they provide data context
* How to transform our projects into graph structures
* Optimizing the model for our use case
* Accessing data through queries, analysis, visualization, applications, and more!

Jennifer Reif

August 16, 2022
Tweet

More Decks by Jennifer Reif

Other Decks in Technology

Transcript

  1. Jennifer Reif Email: jennifer.reif@neo4j.com Twitter: @JMHReif LinkedIn: linked.com/in/jmhreif Github: github.com/JMHReif

    Website: jmhreif.com Graph Databases Solving Problems with Connected Data
  2. Who Am I? • Developer + Advocate • Continuous learner

    • Blogger • Speaker • Other: geek Jennifer Reif Email: jennifer.reif@neo4j.com Twitter: @JMHReif LinkedIn: linked.com/in/jmhreif Github: github.com/JMHReif Website: jmhreif.com
  3. It’s all about data Everything is built on data •

    Businesses, industry, governments, economics, people • Our understanding of the world • Data is how we learn • Trial and error • Asking questions • Accumulated over time
  4. Domain-Driven Design (DDD) • Mutual understanding of domain, concepts •

    Iterations • Understanding data = better understanding of result • Better product, minimum functionality • Sanity check code
  5. Databases - another one?!

  6. Relational database • Pros: • Slices of data that can

    be easily assembled with queries • Handles data integrity and unique rows, low data duplication • Cons: • All relationships must be assembled with JOINs (with NF adherence) • JOINs are constructed from human knowledge Goal: Assemble data into meaningful sets
  7. Entity-Relationship Diagram

  8. NoSQL/Document database • Pros: • Can handle varied (unstructured) data

    more readily • Groups related info in a single place • Cons: • Designed to avoid JOINs and SQL • Makes aggregation operations cumbersome Goal: Group related info together
  9. NoSQL/Document Schema

  10. Graph database Goal: Best of both worlds • Pros: •

    Relationships stored with related entities, no assembly required • Make JOIN operations easy, visual even • Cons: • Storing relationships requires some write operation overhead • Di ff erent mentality for modeling, querying, etc
  11. Graph databases

  12. Have to pick just one? • Polyglot persistence: • Using

    multiple persistence strategies, each serving a di ff erent need • “Using the right tool for the job”
  13. What is a graph?

  14. Graph History Leonard Euler Seven Bridges of Konigsberg problem. Leonhard

    Euler, 1735
  15. Graph databases 2010 New tech arises from… • Solution need

    • Missing solution in the technology space • Looking for a “better way” to handle certain problems
  16. What Does It Solve? Product use case • Document path

    (not just data) • Answering how and why • Understanding connections • Find alternates, impacts, etc. • Produce better assumptions, decisions
  17. Graphs add context and meaning Not just point-to-point, but HOW

    they connect
  18. Misconceptions “Gotchas” • Database - physical storage of data •

    Not just analysis tool • Not just visualization • Can be “system of record” / “source of truth” db • Not just analytics workloads, transactional too • Not a silver bullet (like any technology) • There are things it does NOT do well
  19. Graph Structure

  20. Whiteboard Friendliness Easy to design and model direct representation of

    the data
  21. Data model drawn = real-world data model

  22. Data model drawn = data stored in graph

  23. Graph components • Node (vertex) • Relationship (edge)

  24. Nodes Graph Components • Represent objects or entities • Can

    be labeled Order Product
  25. Nodes Graph components • Represent objects or entities • Can

    be labeled • May have properties Order Product Employee orderId: 162468 total: $8320.48 productId: 08746589 name: “Ipoh Coffee” id: 247924 startDate: 2016-05-04 role: “Salesperson”
  26. Relationships Graph components • Must have a type • Must

    have a direction Order Product Employee orderId: 162468
  27. Relationships Graph components • Must have a type • Must

    have a direction • May have properties Order Product Employee orderId: 162468 commission: .02
  28. Relationships Graph components • Must have a type • Must

    have a direction • May have properties • Nodes can share multiple relationships Order Product Employee orderId: 162468
  29. Label Graph Components • A group of nodes • Like

    a category Person
  30. Label Graph Components • A group of nodes • Like

    a category Person Employee Customer
  31. Property Graph components • Key-value pair • Associated with node

    or relationship • Like a variable name and value Order Employee orderId: 162468 id: 247924 SOLD total: $8320.48 date: 2022-08-16 commission: .02 startDate: 2016-05-04 role: “Salesperson”
  32. Query Language

  33. SQL vs Cypher SELECT o.OrderId, o.Total, o.Items, op.Quantity, op.Price, p.Name

    FROM Order o LEFT JOIN OrderedProduct op ON op.OrderId = o.OrderId LEFT JOIN Product p ON op.ProductId = p.ProductId; SQL Cypher MATCH (o:Order)-[r:CONTAINS]->(p:Product) RETURN o, r, p; Order Product OrderedProduct Order Product
  34. Cypher • Functional and visual • Based on ASCII-art •

    Declarative query language • Focuses on what to retrieve • Not how A B LIKES MATCH (A)-[:LIKES]->(B)
  35. Cypher: powerful and expressive Jennifer Neo4j WORKS_FOR CREATE (:Person {

    name: ‘Jennifer’}) -[:WORKS_FOR]-> (:Company { name: ‘Neo4j’}) NODE PROPERTY NODE PROPERTY LABEL LABEL
  36. Cypher: read Jennifer Neo4j WORKS_FOR MATCH (:Person { name: ‘Jennifer’}

    ) -[:WORKS_FOR]-> ( whom ) 
 RETURN whom
  37. Cypher in 20 seconds… • Nodes look like this: •

    (var:Label) OR (var:Label {propKey: propValue}) • Relationships look like this: • -[var:REL_TYPE]-> OR -[var:REL_TYPE {propKey: propValue}]-> • Using Cypher is looking for patterns of those nodes/rels: • (var1:Label)-[var2:REL_TYPE]->(var3:Label)
  38. Building Applications

  39. Building applications • Drivers: lots of languages supported • Plugins/extensions/libraries:

    • APOC utilities • Graph Data Science • GraphQL • …and more! • Integrations/frameworks: • Spring, Micronaut, Quarkus • Kettle, Spark, PowerBI, JDBC, etc.
  40. Demo!

  41. Resources • Neo4j AuraDB Free: dev.neo4j.com/aura-java • Neo4j GraphAcademy: dev.neo4j.com/learn

    • Neo4j blog: dev.neo4j.com/blog • Neo4j YouTube: dev.neo4j.com/videos Jennifer Reif Email: jennifer.reif@neo4j.com Twitter: @JMHReif LinkedIn: linked.com/in/jmhreif Github: github.com/JMHReif Website: jmhreif.com