Intro to Neo4j for Developers Jennifer Reif Developer Relations Engineer, Neo4j jennifer.reif@neo4j.com @JMHReif
Who Am I? • Developer Relations Engineer for Neo4j • Continuous learner • Conference speaker • Tech blogger • Hobbies: cats, co ff ee, horses, traveling Email: jennifer.reif@neo4j.com Twitter: @JMHReif
What is a graph? • Set of discrete objects, each of which has some set of relationships with other objects Seven Bridges of Konigsberg problem. Leonhard Euler, 1735
What does graph have to offer?
Show how data is connected
Relational Graph
Other NoSQL Graph
Graphs add context and meaning
A few graph use cases… Social network Fraud detection Network & IT operations Identity & access management Graph-based search
(Graphs)-[ARE]->(Everywhere) The Internet Bank Fraud
Literally… Game of Thrones family trees NASA space satellite
Neo4j is a graph database
Neo4j is a database Reliable ACID transactions Neo4j
Neo4j is a database Reliable ACID transactions Neo4j Clustering scale & availability
Neo4j is a database Binary & HTTP Reliable protocol Official Drivers ACID transactions Neo4j Clustering scale & availability
Neo4j is a graph database Graph Storage Neo4j Native Graph Engine Schema Free
Neo4j is a graph database Graph Storage Property Graph Neo4j Model Native Graph Engine Schema Free
Whiteboard Friendliness Easy to design and model direct representation of the model
Whiteboard friendliness
Whiteboard friendliness Movie Character APPEARS_IN title: The Lord of the Rings… name: Frodo Baggins released: 2003 N I _ S PLAYED APPEARS_IN R A Cast E P P A name: Elijah Wood Character name: Aragorn Character name: Legolas PLAYED Cast P L A Y name: Orlando Bloom E D Cast name: Viggo Mortensen
Whiteboard friendliness
How to construct a graph
Property graph data model • 2 main components: • Nodes • Relationships • Additional components: • Labels • Properties
Property graph data model • Nodes Person • Represent the objects in the graph • Can be categorized using Labels Technology Company Person
Property graph data model • Nodes Person • Represent the objects in the graph • Can be categorized using Labels :IS_FRIENDS_WITH • Relationships • Relate nodes by type and Technology Company direction :LIKES :WORKS_FOR Person
Property graph data model • Nodes Person • Represent the objects in the graph name: Michael • Can be categorized using Labels :IS_FRIENDS_WITH since: 2018 • Relationships • Relate nodes by type and Technology Company type: Graphs name: Neo4j direction • Properties • Name/value pairs that can be :LIKES :WORKS_FOR applied to nodes or relationships Person name: Jennifer
Neo4j is a graph database Graph Storage Property Graph Neo4j Model Native Graph Extensible Engine Procedures & Functions Cypher Schema Query Free Language
Cypher Query Language… SQL for Graphs
Functional and visual • Based on ASCII-art LIKES A B • Declarative query language MATCH ( A ) - [ : LIKES] - > ( B ) • Focuses on what to retrieve, not how
Cypher: powerful and expressive WORKS_FOR Neo4j Jennifer NODE NODE CREATE (:Person { name: ‘Jennifer’}) -[:WORKS_FOR]-> (:Company { name: ‘Neo4j’}) LABEL LABEL PROPERTY PROPERTY
Cypher: powerful and expressive WORKS_FOR Neo4j Jennifer MATCH (:Person { name: ‘Jennifer’} ) -[:WORKS_FOR]-> ( whom ) RETURN whom
Neo4j is a graph database Tools & Graph Libraries Storage Property Graph Graph Neo4j Visualization Model Native Graph Extensible Engine Procedures & Functions Cypher Schema Query Free Language
Lord of the Rings graph
Demo Time!!
Resources • Neo4j download: neo4j.com/download/ • Neo4j sandbox: neo4j.com/sandbox/ • Developer guides: neo4j.com/developer/get-started/ • Cypher: neo4j.com/developer/cypher • Data import: neo4j.com/developer/data-import/ • Neo4j certification: neo4j.com/graphacademy/neo4j-certification/ @JMHReif jennifer.reif@neo4j.com
Hunger Games Questions for “Introduction to Neo4j for Developers” 1. Easy: What is Neo4j’s query language? a. GQL b. Cypher c. Gremlin 2. Medium: What graph data model does Neo4j use? a. Short answer: ______________________ 3. Hard: On Jennifer’s data, what did this Cypher clause tell us? WHERE size((a)-[:PLAYED]->(:Character)) > 1 b. Ignore Actors who played more than 1 Character c. Retrieve how many Cast members played a Character d. Find patterns where Cast members played more than 1 Character Answer here: r.neo4j.com/hunger-games
Recommend
More recommend