Download presentation
Presentation is loading. Please wait.
Published byLiam Laye Modified over 9 years ago
2
Square Pegs and Round Holes on the NOSQL World Jim Webber Chief Scientist, Neo Technology @jimwebber
3
Koans A free tutorial that gets you up to speed with Neo4j through hacking http://bit.ly/neo4j-koan https://github.com/jimwebber/neo4j-tutorial
4
Not Only SQL Remember that NOSQL means
5
http://www.flickr.com/photos/crazyneighborlady/355232758/
6
http://gallery.nen.gov.uk/image82582-.html
7
http://www.xtranormal.com/watch/6995033/mongo-db-is-web-scale
8
http://www.orangesmile.com/destinations/img/berlin-map-metro-big.gif
9
Creating 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(); }
10
Creating Relationships 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(); }
11
http://malden-dsme.co.uk/public/hcj.html
12
http://easystreetdiscount.auctivacommerce.com/Nirvana-Smiley-Face-Music-Band-Decal-Sticker-P188162.aspx
13
http://www.tolkienlibrary.com/press/922-Isildur_Poker_Champion.php
14
http://www.vaccinetimes.com/wp-content/uploads/2010/12/microscope.jpg
15
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
16
Application 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
17
Graph Database username: Jeff1986 age: 25 username: SallyDJ age: 28 username: FunkySam age: 24 username: Gazza age: 32 FRIEND
18
http://www.freewebs.com/fictionfrek101/han.jpg
19
Graph Database username: SallyDJ age: 28 product: CoolDecks manufacturer : Acme price : 599 PURCHASE D product: SuperCans manufacturer : Acme price : 150 PURCHASE D username: Gazza age: 32 PURCHASE D 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
20
http://xkcd.com/653/
21
Graph Database product: CoolDecks manufacturer : Acme price : 599 PURCHASE D product: SuperCans manufacturer : Acme price : 150 PURCHASE D username: Jeff1986 age: 25 username: SallyDJ age: 28 username: FunkySam age: 24 username: Gazza age: 32 FRIEND
22
http://void.iddqd.cz/comic-book-guy-pc.jpg
23
Graph Algorithms What’s the shortest path between the Doctor and the Master? Node theMaster = … Node theDoctor = … int maxDepth = 5; PathFinder shortestPathFinder = GraphAlgoFactory.shortestPath( Traversal.expanderForAllTypes(), maxDepth); Path shortestPath = shortestPathFinder.findSinglePath(theDoctor, theMaster);
24
Path finding Find all the episodes where Rose Tyler fought the Daleks
25
Path finder code Node rose =... Node daleks =... PathFinder pathFinder = GraphAlgoFactory.pathsWithLength( Traversal.expanderForTypes( DoctorWhoUniverse.APPEARED_IN, Direction.BOTH), 2); Iterable paths = pathFinder.findAllPaths(rose, daleks); algo constraints fixed path length
26
age: < 40 PURCHASED product: SuperCans manufacturer : Acme product: CoolDecks manufacturer : Acme !PURCHASED
27
Why graph matching? It’s super-powerful for looking for patterns in a data set – TW has done retail analytics PoCs (and hopefully projects) with this stuff Higher-level abstraction than raw traversers – Uses PatternNode and PatternRelationship types to describe graph patterns – The “unbound” parts of the graph
28
In which episodes did the Doctor battle the Cybermen?
29
Setting up and matching a pattern 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 matches = matcher.match(theDoctor, universe.theDoctor());
30
http://male-ejaculation.net/
31
http://www.561studios.com/blog/wp-content/uploads/2010/07/commonsense.jpg
32
Questions? Community: http://neo4j.org Koans: https://github.com/jimwebber/neo4j-tutorial Me: @jimwebber, jim@neotechnology.com
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.