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

Neo4j a bit of math and magic

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Neo4j a bit of math and magic

Light intro into graph database Neo4j presented at Sloboda studio EDU project.

tetiana chupryna

June 11, 2015

Transcript

15 slides
  1. N E O 4 J A L I T T

    L E B I T O F M A T H A N D M A G I C
  2. G R A P H S A R E E

    V E RY W H E R E !
  3. O T H E R Q U E S T

    I O N S • What film should I see tonight? • Where should I have a lunch? • How can I get there? • How can I get the cheapest tickets for a flight?
  4. U S U A L LY W E U S

    E R E L AT I O N S
  5. G R A P H D ATA B A S

    E S A LT E R N A T I V E I S
  6. G R A P H D ATA B A S

    E S • Neo4j • FlockDB • AllegroGraph • GraphDB • InfiniteGraph • OrientDB
  7. I S I T R E A L LY A

    H I P S T E R T H I N G ? • Java • Community/Enterprise edition • ASID compliant, cluster support, runtime failover • Used by many companies
  8. C Y P H E R • It’s like SQL

    but for graphs MATCH (user)-[:friend]->(follower) WHERE user.name IN ['Joe', 'John', 'Sara', 'Maria', 'Steve'] AND follower.name =~ ’S.*' LIMIT 5 RETURN user.name, follower.name
  9. O K , N E O 4 J I S

    F O R TA S K S W H E R E D ATA I S A G R A P H . ( W H E R E Y O U H A V E A L O T O F J O I N S )
  10. Q U I C K S TA RT • http://neo4j.com/download/

    • bin/neo4j start • locahost:7474
  11. S O M E E X A M P L

    E S MATCH ()-[r:ACTED_IN]->() RETURN r MATCH (gene:Person)-[:ACTED_IN]->(m), (other)-[:ACTED_IN]->(m) WHERE gene.name="Gene Hackman" RETURN DISTINCT other; MATCH (a:Person)-[:ACTED_IN]->(m) RETURN a.name, count(m) ORDER BY count(m) DESC LIMIT 10; MATCH (tom:Person)-[:ACTED_IN]->()<-[:ACTED_IN]-(a:Person) WHERE tom.name="Tom Hanks" AND a.born < tom.born RETURN a.name;
  12. MATCH (kevin:Person { name:"Kevin Bacon" }), (al:Person { name:"Al Pacino"

    }), p = shortestPath((kevin)-[*..15]-(al)) RETURN p MATCH p=shortestPath((kevin:Person)-[r:ACTED_IN*]-(actor)) WHERE kevin.name='Kevin Bacon' AND actor.name='Al Pacino' RETURN length([m in nodes(p) WHERE m:Movie]) as BaconNumber, [m in nodes(p) WHERE m:Movie | m.title] as Movies, [a in nodes(p) WHERE a:Person | a.name][1..-1] as KnowsActors

More Decks by tetiana chupryna

Other Decks in Programming