Slide 1

Slide 1 text

Pouring Coffee into the Matrix Building Java applications on Neo4j Jennifer Reif [email protected] @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif

Slide 2

Slide 2 text

Who is Jennifer Reif? Developer Advocate, Neo4j • Continuous learner • Conference speaker • Tech blogger • Other: geek Jennifer Reif [email protected] @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif

Slide 3

Slide 3 text

What is graph?

Slide 4

Slide 4 text

What is graph? • Database - data storage • Way to store relationships with entities • Powerful when… • Queried - results based on the network structure • Visualized - depth comprehension of network • Utilized in algorithms/pipelines - factoring network into calculations

Slide 5

Slide 5 text

Graph history • Much older than technology… • Arose from solution need (then and now) Seven Bridges of Konigsberg problem. Leonhard Euler, 1735

Slide 6

Slide 6 text

Graph Data Model

Slide 7

Slide 7 text

Property graph • Node (vertex) • Relationship (edge)

Slide 8

Slide 8 text

Nodes • Represent objects or entities • Can be labeled Category Feature JavaVersion

Slide 9

Slide 9 text

Nodes • Represent objects or entities • Can be labeled • May have properties Category Feature JavaVersion version: “17” gaDate: 2021-09-14 name: “lang” title: “Pattern Matching for switch”

Slide 10

Slide 10 text

Relationships • Must have a type • Must have a direction (stored) • Can be read in either direction Category Feature JavaVersion version: “17” gaDate: 2021-09-14 INCLUDES BELONGS_TO name: “lang” title: “Pattern Matching for switch”

Slide 11

Slide 11 text

Relationships • Must have a type • Must have a direction (stored) • Can be read in either direction • May have properties Category Feature JavaVersion version: “17” gaDate: 2021-09-14 INCLUDES BELONGS_TO featureCount: 3 CHANGES name: “lang” title: “Pattern Matching for switch”

Slide 12

Slide 12 text

Relationships • Must have a type • Must have a direction (stored) • Can be read in either direction • May have properties • Nodes can have multiple relationships Category Feature JavaVersion version: “17” gaDate: 2021-09-14 INCLUDES BELONGS_TO featureCount: 3 CHANGES STARTED_IN name: “lang” title: “Pattern Matching for switch” IM PACTED_BY

Slide 13

Slide 13 text

Label • Group of nodes • Like a category • Domain class :) Person

Slide 14

Slide 14 text

Label • Group of nodes • Like a category • Domain class :) • Inheritance :) Person Employee Customer

Slide 15

Slide 15 text

Properties • Key-value pair • Associated with node or relationship • Like a variable name and value Category JavaVersion version: “17” CHANGES gaDate: 2021-09-14 featureCount: 3 version: “6” codeName: “Mustang”

Slide 16

Slide 16 text

Modeling

Slide 17

Slide 17 text

Whiteboard friendliness

Slide 18

Slide 18 text

Graph data

Slide 19

Slide 19 text

Java dev: why graph?

Slide 20

Slide 20 text

Answering data questions • Java versions (i.e. 8, 11, 17) • Changes between versions over time • Di ff s • History for one speci fi c feature

Slide 21

Slide 21 text

Domain/Application alignment • Class • Entity/Object • Represents domain type • Variables/Properties • Details for that entity • Constructor - instance of object • Each instance is unique object with varying info @Node public class JavaVersion { @Id @Property("version") private fi nal String javaVersion; private String name, codeName, status, apiSpec; private LocalDate gaDate, eolDate; }

Slide 22

Slide 22 text

Retaining relationships • Adding relationships • Add variable as pointer to another object • Links entities together • Might have some annotations for mapping @Node public class JavaVersion { @Relationship(“FROM_NEWER”) private List olderVersionDiffs; }

Slide 23

Slide 23 text

Prep for code!

Slide 24

Slide 24 text

Neo4j - cloud AuraDB • Free tier • Java language version data loaded

Slide 25

Slide 25 text

Language drivers • Neo4j Java driver (o ffi cial) • Spring Data Neo4j (SDN) • Includes Java driver dependency • Other options: • O ffi cial drivers -> Python, JavaScript, Go, .NET • Java frameworks -> Quarkus, Helidon, Micronaut, etc

Slide 26

Slide 26 text

Spring provisions • Spring Initializr • SB reduce boilerplate • Annotation-based OGM for POJOs • Query derivation + DSL for custom (Cypher) • Spring Data easy-connect to Neo4j

Slide 27

Slide 27 text

Let’s code!

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Resources • Code: github.com/JMHReif/pouring-co ff ee-into-matrix • Spring Data Neo4j docs: dev.neo4j.com/sdn-docs • Neo4j AuraDB: dev.neo4j.com/aura-java • NODES: dev.neo4j.com/nodes24 Jennifer Reif [email protected] @JMHReif github.com/JMHReif jmhreif.com linkedin.com/in/jmhreif