the NOSQL World Jim Webber Chief Scien?st, Neo Technology - - PowerPoint PPT Presentation

the nosql world
SMART_READER_LITE
LIVE PREVIEW

the NOSQL World Jim Webber Chief Scien?st, Neo Technology - - PowerPoint PPT Presentation

Square Pegs and Round Holes in the NOSQL World Jim Webber Chief Scien?st, Neo Technology @jimwebber A rapid talk about Neo4j (and rants on other


slide-1
SLIDE 1

Square ¡Pegs ¡and ¡Round ¡Holes ¡in ¡ the ¡NOSQL ¡World ¡

Jim ¡Webber ¡ Chief ¡Scien?st, ¡Neo ¡Technology ¡ @jimwebber ¡

slide-2
SLIDE 2

A ¡rapid ¡talk ¡about ¡Neo4j ¡ (and ¡rants ¡on ¡other ¡stuff) ¡

Jim ¡Webber ¡ Chief ¡Scien?st, ¡Neo ¡Technology ¡ @jimwebber ¡

slide-3
SLIDE 3

hMp://slantmagazine.com/film/review/saturday-­‑night-­‑fever/4210 ¡

slide-4
SLIDE 4

hMp://freenewfoundlandlabrador.blogspot.com/2011/07/nl-­‑fisheries-­‑500-­‑years-­‑of-­‑turmoil.html ¡

slide-5
SLIDE 5

hMp://www.oopsla.org/oopsla2008/support ¡

slide-6
SLIDE 6

hMp://uncyclopedia.wikia.com/wiki/File:Square-­‑earth.jpg ¡

slide-7
SLIDE 7

hMp://www.telegraph.co.uk/finance/newsbysector/industry/8470355/The-­‑fall-­‑and-­‑rise-­‑of-­‑the-­‑Bri?sh-­‑car-­‑industry-­‑?meline.html ¡

slide-8
SLIDE 8

Bomb ¡the ¡argies! ¡ Crush ¡the ¡miners! ¡ Defy ¡Europe! ¡ I’m ¡CEO, ¡bitch! ¡

hMp://www.answers.com/topic/margaret-­‑thatcher-­‑large-­‑image-­‑3 ¡

slide-9
SLIDE 9

hMp://www.themoviedb.org/movie/26305 ¡

slide-10
SLIDE 10

hMp://iremedy.net/blog/2010/05/your-­‑office-­‑without-­‑boundaries/ ¡

slide-11
SLIDE 11

Share ¡everything! ¡ Social ¡graph! ¡ ¡ I’m ¡CEO, ¡bitch! ¡

slide-12
SLIDE 12

hMp://morganlinton.com/why-­‑there-­‑is-­‑no-­‑one-­‑size-­‑fits-­‑all-­‑development-­‑solu?on/ ¡

slide-13
SLIDE 13

hMp://www.flickr.com/photos/crazyneighborlady/355232758/ ¡

slide-14
SLIDE 14

hMp://gallery.nen.gov.uk/image82582-­‑.html ¡

slide-15
SLIDE 15

hMp://www.xtranormal.com/watch/6995033/mongo-­‑db-­‑is-­‑web-­‑scale ¡

slide-16
SLIDE 16

hMp://www.orangesmile.com/des?na?ons/img/berlin-­‑map-­‑metro-­‑big.gif ¡

slide-17
SLIDE 17

Neo4j: ¡Crea?ng ¡Nodes ¡

GraphDatabaseService db = new EmbeddedGraphDatabase("/tmp/neo");

Transaction tx = db.beginTx(); try { Node theDoctor = db.createNode(); theDoctor.setProperty("name", "the Doctor"); tx.success(); } finally { tx.finish(); }

slide-18
SLIDE 18

Neo4j: ¡Crea?ng ¡Rela?onships ¡

Transaction tx = db.beginTx(); try { Node theDoctor = db.createNode(); theDoctor.setProperty("name", "The Doctor"); Node susan = db.createNode(); susan.setProperty("firstname", "Susan"); susan.setProperty("lastname", "Campbell"); susan.createRelationshipTo(theDoctor, DynamicRelationshipType.withName("COMPANION_OF")); tx.success(); } finally { tx.finish(); }

slide-19
SLIDE 19

hMp://malden-­‑dsme.co.uk/public/hcj.html ¡

slide-20
SLIDE 20

hMp://easystreetdiscount.auc?vacommerce.com/Nirvana-­‑Smiley-­‑Face-­‑Music-­‑Band-­‑Decal-­‑S?cker-­‑P188162.aspx ¡

slide-21
SLIDE 21

hMp://www.tolkienlibrary.com/press/922-­‑Isildur_Poker_Champion.php ¡

slide-22
SLIDE 22

hMp://www.vaccine?mes.com/wp-­‑content/uploads/2010/12/microscope.jpg ¡

slide-23
SLIDE 23

Document ¡Database ¡

username: Jeff1986 age: 25 friend : SallyDJ friend : Gazza username: SallyDJ age: 28 friend : Jeff1986 friend: FunkySam username: FunkySam age: 24 friend : SallyDJ username: Gazza age: 32 friend : Jeff1986

slide-24
SLIDE 24

Applica?on ¡Layer ¡

username: Jeff1986 age: 25 username: SallyDJ age: 28 username: FunkySam age: 24 username: Gazza age: 32

Document ¡Database ¡

username: Jeff1986 age: 25 friend : SallyDJ friend : Gazza username: SallyDJ age: 28 friend : Jeff1986 friend: FunkySam username: FunkySam age: 24 friend : SallyDJ username: Gazza age: 32 friend : Jeff1986

Reify ¡

slide-25
SLIDE 25

Graph ¡Database ¡

username: Jeff1986 age: 25 username: SallyDJ age: 28 username: FunkySam age: 24 username: Gazza age: 32

FRIEND FRIEND FRIEND

slide-26
SLIDE 26

hMp://www.freewebs.com/fic?onfrek101/han.jpg ¡

slide-27
SLIDE 27

Graph ¡Database ¡

username: SallyDJ age: 28 product: CoolDecks manufacturer : Acme price : 599

PURCHASED

product: SuperCans manufacturer : Acme price : 150

P U R C H A S E D

username: Gazza age: 32

PURCHASED

Document ¡Database ¡

username: SallyDJ age: 28 purchased : CoolDecks purchased : SuperCans username: Gazza age: 32 purchased : SuperCans product: SuperCans manufacturer : Acme price : 150 product: CoolDecks manufacturer : Acme price : 599

slide-28
SLIDE 28

hMp://xkcd.com/653/ ¡

slide-29
SLIDE 29

Graph ¡Database ¡

product: CoolDecks manufacturer : Acme price : 599

P U R C H A S E D

product: SuperCans manufacturer : Acme price : 150

PURCHASED PURCHASED

username: Jeff1986 age: 25 username: SallyDJ age: 28 username: FunkySam age: 24 username: Gazza age: 32

FRIEND F R I E N D FRIEND

slide-30
SLIDE 30

hMp://void.iddqd.cz/comic-­‑book-­‑guy-­‑pc.jpg ¡

slide-31
SLIDE 31

stole ¡ from ¡ loves ¡ loves ¡ enemy ¡ enemy ¡

A ¡Good ¡Man ¡ Goes ¡to ¡War ¡

appeared ¡ ¡ in ¡ appeared ¡ ¡ in ¡ appeared ¡ ¡ in ¡ appeared ¡ ¡ in ¡

Victory ¡of ¡ ¡ the ¡Daleks ¡

appeared ¡ ¡ in ¡ appeared ¡ ¡ in ¡ companion ¡ companion ¡ enemy ¡

slide-32
SLIDE 32

Graph ¡Algorithms ¡

What’s ¡the ¡shortest ¡path ¡between ¡the ¡Doctor ¡and ¡the ¡Master? ¡

Node theMaster = … Node theDoctor = … int maxDepth = 5; PathFinder<Path> shortestPathFinder = GraphAlgoFactory.shortestPath( Traversal.expanderForAllTypes(), maxDepth); Path shortestPath = shortestPathFinder.findSinglePath(theDoctor, theMaster);

slide-33
SLIDE 33

Path ¡finding ¡

Find ¡all ¡the ¡episodes ¡where ¡Rose ¡Tyler ¡fought ¡the ¡Daleks ¡

slide-34
SLIDE 34

Path ¡finder ¡code ¡

Node rose = ... Node daleks = ... PathFinder<Path> pathFinder = GraphAlgoFactory.pathsWithLength( Traversal.expanderForTypes( DoctorWhoUniverse.APPEARED_IN, Direction.BOTH), 2); Iterable<Path> paths = pathFinder.findAllPaths(rose, daleks);

algo ¡ constraints ¡ fixed ¡path ¡length ¡

slide-35
SLIDE 35

age: < 40

PURCHASED

product: SuperCans manufacturer : Acme

Graph&Database&

product: CoolDecks manufacturer : Acme price : 599

P U R C H A S E D

product: SuperCans manufacturer : Acme price : 150

P U R C H A S E D PURCHASED

username: Jeff1986 age: 25 username: SallyDJ age: 28 username: FunkySam age: 24 username: Gazza age: 32

FRIEND FRIEND FRIEND

product: CoolDecks manufacturer : Acme

!PURCHASED

slide-36
SLIDE 36

Why ¡graph ¡matching? ¡

  • It’s ¡super-­‑powerful ¡for ¡looking ¡for ¡paMerns ¡in ¡

a ¡data ¡set ¡

– Retail ¡analy?cs ¡ – Real-­‑?me ¡upselling ¡

  • Higher-­‑level ¡abstrac?on ¡than ¡raw ¡traversers ¡

– Uses ¡PatternNode ¡and ¡ PatternRelationship ¡types ¡to ¡describe ¡ graph ¡paMerns ¡ – The ¡“unbound” ¡parts ¡of ¡the ¡graph ¡

slide-37
SLIDE 37

In ¡which ¡episodes ¡did ¡the ¡Doctor ¡ baMle ¡the ¡Cybermen? ¡

slide-38
SLIDE 38

Seong ¡up ¡and ¡matching ¡a ¡paMern ¡

final PatternNode theDoctor = new PatternNode(); theDoctor.setAssociation(universe.theDoctor()); final PatternNode anEpisode = new PatternNode(); anEpisode.addPropertyConstraint("title", CommonValueMatchers.has()); anEpisode.addPropertyConstraint("episode", CommonValueMatchers.has()); final PatternNode aDoctorActor = new PatternNode(); aDoctorActor.createRelationshipTo(theDoctor, DoctorWhoUniverse.PLAYED); aDoctorActor.createRelationshipTo(anEpisode, DoctorWhoUniverse.APPEARED_IN); aDoctorActor.addPropertyConstraint("actor", CommonValueMatchers.has()); final PatternNode theCybermen = new PatternNode(); theCybermen.setAssociation(universe.speciesIndex.get("species", "Cyberman").getSingle()); theCybermen.createRelationshipTo(anEpisode, DoctorWhoUniverse.APPEARED_IN); theCybermen.createRelationshipTo(theDoctor, DoctorWhoUniverse.ENEMY_OF); PatternMatcher matcher = PatternMatcher.getMatcher(); final Iterable<PatternMatch> matches = matcher.match(theDoctor, universe.theDoctor());

slide-39
SLIDE 39

HIPSTER ¡DEVS, ¡Y ¡U ¡NO ¡LIKE ¡JAVA? ¡

slide-40
SLIDE 40

Equivalent ¡Cypher ¡Query ¡

start doctor=(Characters,name,"Doctor"), cybermen=(Species,species,"Cyberman") match (doctor)<-[:PLAYED]-(actor)

  • [:APPEARED_IN]->(ep)

<-[:APPEARED_IN]-(cybermen) where ep.title and ep.episode return ep.title, actor.actor

slide-41
SLIDE 41

Cold ¡cache! ¡

slide-42
SLIDE 42

hMp://male-­‑ejacula?on.net/ ¡

slide-43
SLIDE 43

hMp://www.561studios.com/blog/wp-­‑content/uploads/2010/07/commonsense.jpg ¡

slide-44
SLIDE 44

Hands-­‑on ¡tutorial ¡tomorrow! ¡

Sign ¡up ¡with ¡the ¡ ¡conference ¡organisers ¡

slide-45
SLIDE 45

Thanks ¡for ¡listening ¡

Community: ¡h1p://neo4j.org ¡ Koans: ¡h1ps://github.com/jimwebber/neo4j-­‑tutorial ¡ Me: ¡@jimwebber ¡