Stephan
Pirnbaum
:Person
NeosCon
:SPEAKS_AT Dresden
:Conference :City
:IN
An
Introduction
to Neo4j
:Talk
:HOSTS
:SPEAKS_ABOUT
Slide 3
Slide 3 text
https://neo4j.com/blog/neo4j-community-june-2016/
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
The world is a graph
◼ Full of connected people,
events, and other things
◼ Relations matter!
https://www.businessinsider.com/explainer-what-exactly-is-the-social-graph-2012-3?IR=T
Slide 6
Slide 6 text
The IT-world is full of graphs
◼ Software Projects consists of Modules, Packages, Classes, ...
All these are in relation to each other
◼ Where are JOIN-tables in reality (and how do you explain them)?
Slide 7
Slide 7 text
Data volume is increasing
and getting more connected
◼ Online Transactions
◼ Social Networks
◼ Smart Devices
https://www.sensorsexpo.com/iot-ecosystem
Slide 8
Slide 8 text
High value in data relationships
◼ Connecting data on a new way can improve existing and create new
use case
Brings many advantages over competitors
There is plenty of data in todays world created every second
Relational DBs can‘t handle relationships well
◼ Cannot model or store data and relationships without complexity
◼ Performance degrades with number and levels of relationships and DB
size
◼ Query complexity grows with need for JOINs
◼ Adding new types of data and relationships requires schema redesign
Slide 11
Slide 11 text
No content
Slide 12
Slide 12 text
Internal Applications
Master Data Management
Network and IT Operations
Fraud Detection
…
Customer-Facing Applications
Real-Time Recommendations
Graph-Based Search
Identity and Access Management
Knowledge Graph
…
https://neo4j.com/use-cases/
Slide 13
Slide 13 text
Usage for Good
◼ Offshore Leaks
◼ Panama Papers
◼ Paradise Papers
https://neo4j.com/blog/neo4j-power-behind-paradise-papers/
Slide 14
Slide 14 text
Usage for Good
◼ Cancer Research
Candiolo Cancer Institute
◼ Diabetes Research
German Center for
Diabetes Research
https://www.it-zoom.de/it-director/e/diabetesforschung-nutzt-neo4j-21116/
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
ACID-compliant
Transactional
Native graph storage and processing
Property-Graph-Model
Open Source and Commercial Licensing
Offers drivers for: Python, .Net, Java, PHP, …
Slide 17
Slide 17 text
Werner Vogels, CTO of Amazon
Slide 18
Slide 18 text
No content
Slide 19
Slide 19 text
„The Whiteboardmodel is the Graph
Model“
◼ No need for object-relational-mapping
◼ Same understanding of the data model for IT
and business
◼ No need for complex Join-Tables and alike
https://de.slideshare.net/neo4j/the-graph-database-universe-neo4j-overview
Slide 20
Slide 20 text
Nodes
◼ Objects in the graph
◼ Stores data using name-value properties
◼ Can have labels attached
Relationships
◼ Relates nodes by type (Label) and direction
◼ Stores data using name-value properties
Stephan
:Person:Author
Neo4j –
Part 1
:WROTE
:Article
firstName: Stephan
lastName: Pirnbaum
birthday: 26.11.1993
title: Neo4j – Part 4
state: Published
publishedOn: 5/11/2019
Slide 21
Slide 21 text
WROTE
STEPHAN
Neo4j –
Part 1
Relational Model Graph Model
Author Article
Author-Article
STEPHAN
Neo4j – Part 1
Neo4j – Part 3
Neo4j – Part 2
Neo4j –
Part 2
Neo4j –
Part 3
https://logisima.developpez.com/tutoriel/nosql/neo4j/introduction-neo4j/
Slide 22
Slide 22 text
No content
Slide 23
Slide 23 text
Let‘s model
◼ Article
◼ Tag
◼ Category
◼ Person
◼ Author
◼ Comment
Master Data
Activity
Schema Design and Migration
◼ Neo4j has no schema in the classical sense
◼ Definition of indexes on properties possible
◼ Definition of uniqueness/existence constraints for properties possible
Stephan
:Person:Author
Neo4j –
Part 1
:WROTE
:Article
Match (:Author{firstName: ‘‘Stephan“})-[:WROTE]->(article:Article) RETURN article
Node Node
Relationship
LABEL PROPERTY LABEL
VAR
Slide 36
Slide 36 text
Find all authors
MATCH
(a:Author)
RETURN
a.firstName, a.lastName
Slide 37
Slide 37 text
Find all articles of all authors grouped by author
MATCH
(p:Person)-[:WROTE]->(a:Article)
RETURN
p.firstName,
p.lastName,
collect(a {.title, .publishedOn}) AS Articles
Slide 38
Slide 38 text
Let‘s find out who has written articles which are tagged as „Neo4j“
◼ In SQL…
SELECT DISTINCT p.firstName, p.lastName
FROM Person p
LEFT JOIN Article a ON p.personId = a.personId
LEFT JOIN ArticleTag aT ON a.articleId = aT.articleId
LEFT JOIN Tag t ON aT.tagId = t.tagId
WHERE t.name = "Neo4j“
Slide 39
Slide 39 text
Let‘s find out who has written articles which are tagged as
„Neo4j“
◼ In Cypher ☺
MATCH
(p:Author)-[:WROTE]->(a:Article),
(a)-[:TAGGED_BY]->(t:Tag{name: “Neo4j“})
RETURN
DISTINCT p.firstName, p.lastName
Slide 40
Slide 40 text
Find co-occuring tags
◼ Useful to identify new categories
MATCH
(t1:Tag)-->()<--(t2:Tag)
RETURN
t1.name, t2.name, count(*) AS cooccurences
Slide 41
Slide 41 text
Build a recommendation engine for articles
:Person
:Author
:Article
:WROTE :Category
:CONTAINS
:CONTAINS
:Comment :Tag
:WROTE
:HAS_COMMENT
:Person
Slide 42
Slide 42 text
MATCH
(p:Person)-[:COMMENTED]->(a1:Article),
(peer:Person)-[:WROTE|:COMMENTED]->(a1),
(peer:Person)-[:WROTE|:COMMENTED]->(a2:Article)
WHERE
NOT exists((p)-[:COMMENTED]->(a2))
RETURN
a2.title, count(*) AS frequency
ORDER BY
frequency DESC LIMIT 5
Easy modelling of hierarchical data structures
Usage for powerfull recommendation engines
◼ https://www.adamcowley.co.uk/neo4j/wordpress-recommendations-neo4j-part-1-
data-modelling/ (WordPress)
Usage for page-view tracking
◼ https://neo4j.com/blog/graph-databases-drupal-neo4j-module-rules-integration/
(Drupal)
Slide 46
Slide 46 text
Click-Path analysis using Snowplow
◼ https://snowplowanalytics.com/blog/2017/07/17/loading-and-analysing-
snowplow-event-data-in-Neo4j/
Structr is based on Neo4j: https://structr.com/
CMS using GraphQL: https://graphcms.com/
Slide 47
Slide 47 text
No content
Slide 48
Slide 48 text
Please ask questions to: Stephan Pirnbaum
buschmais GbR
Inhaber
Torsten Busch, Frank Schwarz,
Dirk Mahler und Tobias Israel
[email protected]
http://buschmais.de/
Dresden, 11.05.2019