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.
14. Who is Joe’s friend?
MATCH (joe { name: 'Joe' })-[:knows]-(friends)
RETURN joe, friends
15. Joe’s friends of friends
MATCH (joe { name: 'Joe' })-[:knows*2..2]-(fof)
RETURN fof
16. Wait, Joe already knows sara
MATCH (joe { name: 'Joe' })-[:knows*2..2]-(fof)
WHERE NOT(joe-[:knows]-fof)
RETURN fof
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
21. Ask questions
● How many flight canceled
● How many flight delayed
● Average taxi waiting time
● Shortest path between
22. Other way to use neo4j
● Embedded (CTA)
● Server plugin (Grok)
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