Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

An Introduction to Neo4j

2,506 views

Published on

Learn what Neo4j is and why you should use it. Two examples illustrate its utility: a friend-of-a-friend prediction example, and one using flight delays to predict taxi waits at airports.

Published in: Software
  • Login to see the comments

An Introduction to Neo4j

  1. 1. Neo4j Introduction the basic stuff
  2. 2. Agenda ● What / Why ● Learn through an FoF example ● More involved problem: Which airport performans better ● Advance modeling topics
  3. 3. What is it? A Graph Database
  4. 4. A Graph Database
  5. 5. Relational Model
  6. 6. In Graph
  7. 7. Why Graph Database
  8. 8. ● Wicked fast on a type of problem ● Scale up independent of amount of data ● Intuitive modeling ● Fun and Freedom (embedded mode)
  9. 9. Setup (on a mac) $> brew update $> brew install neo4j $> neo4j start $> open http://localhost:7474
  10. 10. 3 way to use * Standalone with Cypher * * Server plugin * Embedded
  11. 11. Cypher is the way get stuff out from Neo4j graph
  12. 12. A FoF example covers Create Match Where Count Order by
  13. 13. Create node/relationship create(joe:Person {name: Joe” }) create(sara:Person {name: “Sara” }) create joe-[:knows]->sara
  14. 14. Who is Joe’s friend? MATCH (joe { name: 'Joe' })-[:knows]-(friends) RETURN joe, friends
  15. 15. Joe’s friends of friends MATCH (joe { name: 'Joe' })-[:knows*2..2]-(fof) RETURN fof
  16. 16. Wait, Joe already knows sara MATCH (joe { name: 'Joe' })-[:knows*2..2]-(fof) WHERE NOT(joe-[:knows]-fof) RETURN fof
  17. 17. Who is more likely to be Joe's friend? MATCH (joe { name: 'Joe' })-[:knows*2..2]-(fof) WHERE NOT(joe-[:knows]-fof) RETURN fof.name, count(*) ORDER BY count(*) DESC, fof.name
  18. 18. A flight/airport example http://gist.neo4j.org/?6619085
  19. 19. Data From http://www.transtats.bts.gov/DL_SelectFields.a sp?Table_ID=236&DB_Short_Name=On-Time
  20. 20. Data model
  21. 21. Ask questions ● How many flight canceled ● How many flight delayed ● Average taxi waiting time ● Shortest path between
  22. 22. Other way to use neo4j ● Embedded (CTA) ● Server plugin (Grok)
  23. 23. Neo4j modeling tips ● Understand the performance character ○ Traversing is fast ○ IO is slow ○ Node properties are lazy loaded/cached ● Normalization verse denormalization in relational database performance tuning

×