Upgrade to Pro — share decks privately, control downloads, hide ads and more …

An Introduction to Neo4j

An Introduction to Neo4j

This talk gives an introduction to the graph database Neo4j and provides infos on:
- when and why to use graph dbs
- Neo4j itself
- how to model, store, and query data

Stephan Pirnbaum

May 11, 2019
Tweet

More Decks by Stephan Pirnbaum

Other Decks in Programming

Transcript

  1. Stephan Pirnbaum :Person NeosCon :SPEAKS_AT Dresden :Conference :City :IN An

    Introduction to Neo4j :Talk :HOSTS :SPEAKS_ABOUT
  2.  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
  3.  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)?
  4.  Data volume is increasing and getting more connected ◼

    Online Transactions ◼ Social Networks ◼ Smart Devices https://www.sensorsexpo.com/iot-ecosystem
  5.  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
  6.  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
  7. 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/
  8.  Usage for Good ◼ Offshore Leaks ◼ Panama Papers

    ◼ Paradise Papers https://neo4j.com/blog/neo4j-power-behind-paradise-papers/
  9.  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/
  10.  ACID-compliant  Transactional  Native graph storage and processing

     Property-Graph-Model  Open Source and Commercial Licensing  Offers drivers for: Python, .Net, Java, PHP, …
  11.  „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
  12.  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
  13. 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/
  14.  Let‘s model ◼ Article ◼ Tag ◼ Category ◼

    Person ◼ Author ◼ Comment Master Data Activity
  15.  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
  16.  Cypher-Based LOAD CSV Capability  Command-Line Bulk Loader bin/neo4j-import

     JSON/XML Loader  ETL Tool for RDBMS  NOSQL DB Access https://neo4j.com/developer/neo4j-etl/
  17. Stephan :Person:Author Neo4j – Part 1 :WROTE :Article Match (:Author{firstName:

    ‘‘Stephan“})-[:WROTE]->(article:Article) RETURN article Node Node Relationship LABEL PROPERTY LABEL VAR
  18.  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
  19.  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“
  20.  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
  21.  Find co-occuring tags ◼ Useful to identify new categories

    MATCH (t1:Tag)-->()<--(t2:Tag) RETURN t1.name, t2.name, count(*) AS cooccurences
  22.  Build a recommendation engine for articles :Person :Author :Article

    :WROTE :Category :CONTAINS :CONTAINS :Comment :Tag :WROTE :HAS_COMMENT :Person
  23.  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)
  24. 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