1 / 32

Mastering Neo4j A Graph Database

Mastering Neo4j A Graph Database. Data Masters. Special Thanks To…. Planet Linux Caffe http :// planetlinuxcaffe.com. We now have a sponsor!!. John Jadvani 954-527-0090. Short bio about me… Andrew Simkovsky 15 years working with database technology

mai
Download Presentation

Mastering Neo4j A Graph Database

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mastering Neo4jA Graph Database Data Masters

  2. Special Thanks To… Planet Linux Caffe http://planetlinuxcaffe.com

  3. We now have a sponsor!! John Jadvani 954-527-0090

  4. Short bio about me… • Andrew Simkovsky • 15 years working with database technology • Oracle, MySQL/MariaDB, SQL Server, Postgres • Redis, MongoDB, CouchDB, Cassandra, Neo4j • Worked across many industries • Consulting, Retail, Telecommunications, Energy • Data, Marketing, Gaming, Health care

  5. DBTekPro www.dbtekpro.com andrew@dbtekpro.com @asimkovsky

  6. Graph Databases

  7. Graph Databases • What is a graph database? • Based on graph theory • Data is stored as “nodes”, and relationships as “edges” • Nodes have attributes. • Relationships have attributes

  8. Relational vs Graph • Relational • Relationships are used to join entities together to get results • Data integrity is enforced through constraints • Graph • Relationships are considered data • Can easily “walk” from node to node using relationships • Can “walk” the graph in multiple directions in parallel

  9. Relational Model actor movie actor_movie actor_id movie_id role actor_id name movie_id title release_date 1, Keanu Reeves 2, Carrie-Ann Moss 3, Lawrence Fishburne 1, 1, Neo 1, 2, Neo 1, 3, Neo 2, 1, Trinity 2, 2, Trinity 2, 3, Trinity 3, 1, Morpheus 3, 2, Morpheus 3, 3, Morpheus 1, The Matrix 2, The Matrix Reloaded 3, The Matrix Revolutions

  10. Graph Model The Matrix The Matrix 2 The Matrix 3 Keanu Reeves Carrie-Ann Moss Lawrence Fishburne

  11. Graph Model - Detailed Node Relationship type: Movie title: “Matrix” type: Actor name: “Keanu Reeves” :ACTS_IN type: Role, role: “Neo” Property Value Property Path

  12. Example Graphs

  13. Example Graphs

  14. Example Graphs

  15. Graph Databases – Examples Uses • Social relationships • Actor / movie relationships • Medicine interactions Just some of the many possibilities!

  16. CypherA Graph Query Language

  17. Queries START [MATCH] [WITH] [WHERE] RETURN [ORDERBY] [SKIP] [LIMIT] Starting node(s) Matching pattern (except properties) Further conditions / calculations Filter on properties Properties to return

  18. Query Example START user=node:nodeIndexName(name={“Bob”}) MATCH (user)-[:FRIEND]->(friend) WITH user, count(friend) as friends WHERE friends > 10 RETURN friend.name ORDER BY friend.name LIMIT 100

  19. Query Parts object type index name property value START user=node:nodeIndexName(name={“Bob”}) made-up identifier node property identifier

  20. Query Parts node node MATCH (user)-[:FRIEND]->(friend) relationship definition (including direction) Another made-up identifier

  21. Query Parts WITH user, count(friend) as friends grouping node alias calculation

  22. Query Parts WHERE friends > 10 property filter

  23. Query Parts RETURN friend.name ORDER BY friend.name LIMIT 100

  24. Query Example – All Together START user=node:nodeIndexName(name={“Bob”}) MATCH (user)-[:FRIEND]->(friend) WITH user, count(friend) as friends WHERE friends > 10 RETURN friend.name ORDER BY friend.name LIMIT 100 This will return all nodes where they are friends with Bob, and that Bob has more than 10 friends, but limit to the first 100 found.

  25. Query Example – Matching START user=node:nodeIndexName(name={“Bob”}) MATCH (user)-[:FRIEND {since: “2001-01-01”} ]->(friend) RETURN friend.name Since relationships have properties, we can search on them too!!

  26. Creating Data CREATE [UNIQUE]* [SET | DELETE | FOREACH]* [RETURN [ORDERBY][SKIP][LIMIT]]

  27. Creating Data - Examples CREATE (n {name: “Bob”}) made-up identifier again property value

  28. Creating Data - Examples CREATE (b {name: “Bob”}), (m {name: “Mary”}), (b)-[:KNOWS]->(m) Creates two nodes with a relationship between them. This is called creating a path.

  29. Creating Data - Examples You can combine queries with create options! This allows you to create parts of the graph starting from a particular node (or nodes)! START b=node:nodeIndexName(name={“Bob”}), m=node:nodeIndexName(name={“Mary”}) MATCH (b)-[:KNOWS]->(m) CREATE (b)-[:LOVES]->(m)

  30. Live Demo!

  31. Where Do I Get It? www.neo4j.org

  32. Thank You For Coming! Please rate this Meet Up: www.meetup.com/data-masters (or go there to join!) Check out my blog and forums: www.dbtekpro.com After Party!! Miller’s Ale House Miracle Mile

More Related