$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: [email protected]
    Twitter: @JMHReif
    LinkedIn: linked.com/in/jmhreif
    Github: github.com/JMHReif
    Website: jmhreif.com
    Graph Databases
    Solving Problems with Connected Data

    View Slide

  2. Who Am I?
    • Developer + Advocate

    • Continuous learner

    • Blogger

    • Speaker

    • Other: geek
    Jennifer Reif
    Email: [email protected]
    Twitter: @JMHReif
    LinkedIn: linked.com/in/jmhreif
    Github: github.com/JMHReif
    Website: jmhreif.com

    View Slide

  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

    View Slide

  4. Domain-Driven Design (DDD)
    • Mutual understanding of domain, concepts

    • Iterations

    • Understanding data = better understanding of result

    • Better product, minimum functionality

    • Sanity check code

    View Slide

  5. Databases - another one?!

    View Slide

  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

    View Slide

  7. Entity-Relationship Diagram

    View Slide

  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

    View Slide

  9. NoSQL/Document Schema

    View Slide

  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

    View Slide

  11. Graph databases

    View Slide

  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”

    View Slide

  13. What is a graph?

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  17. Graphs add context and meaning
    Not just point-to-point, but HOW they connect

    View Slide

  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

    View Slide

  19. Graph Structure

    View Slide

  20. Whiteboard


    Friendliness
    Easy to design and model direct representation of the data

    View Slide

  21. Data model drawn = real-world data model

    View Slide

  22. Data model drawn = data stored in graph

    View Slide

  23. Graph components
    • Node (vertex)

    • Relationship (edge)

    View Slide

  24. Nodes
    Graph Components
    • Represent objects or entities

    • Can be labeled
    Order Product

    View Slide

  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”

    View Slide

  26. Relationships
    Graph components
    • Must have a type

    • Must have a direction
    Order Product
    Employee
    orderId: 162468


    View Slide

  27. Relationships
    Graph components
    • Must have a type

    • Must have a direction

    • May have properties
    Order Product
    Employee
    orderId: 162468


    commission: .02

    View Slide

  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


    View Slide

  29. Label
    Graph Components
    • A group of nodes

    • Like a category
    Person

    View Slide

  30. Label
    Graph Components
    • A group of nodes

    • Like a category
    Person
    Employee
    Customer

    View Slide

  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”

    View Slide

  32. Query Language

    View Slide

  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

    View Slide

  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)

    View Slide

  35. Cypher: powerful and expressive
    Jennifer Neo4j
    WORKS_FOR
    CREATE (:Person { name: ‘Jennifer’}) -[:WORKS_FOR]-> (:Company { name: ‘Neo4j’})
    NODE
    PROPERTY
    NODE
    PROPERTY
    LABEL LABEL

    View Slide

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

    RETURN whom

    View Slide

  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)

    View Slide

  38. Building Applications

    View Slide

  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.

    View Slide

  40. Demo!

    View Slide

  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: [email protected]
    Twitter: @JMHReif
    LinkedIn: linked.com/in/jmhreif
    Github: github.com/JMHReif
    Website: jmhreif.com

    View Slide