slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Square Pegs and Round Holes on the NOSQL World PowerPoint Presentation
Download Presentation
Square Pegs and Round Holes on the NOSQL World

Loading in 2 Seconds...

play fullscreen
1 / 32

Square Pegs and Round Holes on the NOSQL World - PowerPoint PPT Presentation


  • 101 Views
  • Uploaded on

Square Pegs and Round Holes on the NOSQL World. Jim Webber Chief Scientist, Neo Technology @ jimwebber. 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. N ot O nly S QL.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Square Pegs and Round Holes on the NOSQL World' - jaegar


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
square pegs and round holes on the nosql world

Square Pegs and Round Holes on the NOSQL World

Jim Webber

Chief Scientist, Neo Technology

@jimwebber

koans a free tutorial that gets you up to speed with neo4j through hacking

KoansA free tutorial that gets you up to speed with Neo4j through hacking

http://bit.ly/neo4j-koan

https://github.com/jimwebber/neo4j-tutorial

n ot o nly s ql

Not OnlySQL

Remember that NOSQL means

slide7

http://www.xtranormal.com/watch/6995033/mongo-db-is-web-scalehttp://www.xtranormal.com/watch/6995033/mongo-db-is-web-scale

slide8

http://www.orangesmile.com/destinations/img/berlin-map-metro-big.gifhttp://www.orangesmile.com/destinations/img/berlin-map-metro-big.gif

creating nodes
Creating Nodes

GraphDatabaseServicedb = new EmbeddedGraphDatabase("/tmp/neo");

Transaction tx = db.beginTx();

try {

Node theDoctor = db.createNode();

theDoctor.setProperty("name", "the Doctor");

tx.success();

} finally {

tx.finish();

}

creating relationships
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();

}

slide12

http://easystreetdiscount.auctivacommerce.com/Nirvana-Smiley-Face-Music-Band-Decal-Sticker-P188162.aspxhttp://easystreetdiscount.auctivacommerce.com/Nirvana-Smiley-Face-Music-Band-Decal-Sticker-P188162.aspx

slide13

http://www.tolkienlibrary.com/press/922-Isildur_Poker_Champion.phphttp://www.tolkienlibrary.com/press/922-Isildur_Poker_Champion.php

slide14

http://www.vaccinetimes.com/wp-content/uploads/2010/12/microscope.jpghttp://www.vaccinetimes.com/wp-content/uploads/2010/12/microscope.jpg

slide15

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

slide16

Application Layer

username: SallyDJ

age: 28

username: Jeff1986

age: 25

username: FunkySam

age: 24

username: Gazza

age: 32

Reify

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

slide17

Graph Database

username: SallyDJ

age: 28

FRIEND

FRIEND

username: Jeff1986

age: 25

username: FunkySam

age: 24

FRIEND

username: Gazza

age: 32

slide19

Graph Database

username: Gazza

age: 32

username: SallyDJ

age: 28

PURCHASED

PURCHASED

PURCHASED

product: SuperCans

manufacturer : Acme

price : 150

product: CoolDecks

manufacturer : Acme

price : 599

Document Database

product: SuperCans

manufacturer : Acme

price : 150

product: CoolDecks

manufacturer : Acme

price : 599

username: SallyDJ

age: 28

purchased : CoolDecks

purchased : SuperCans

username: Gazza

age: 32

purchased : SuperCans

slide21

Graph Database

username: Jeff1986

age: 25

username: FunkySam

age: 24

FRIEND

username: Gazza

age: 32

FRIEND

FRIEND

username: SallyDJ

age: 28

PURCHASED

PURCHASED

PURCHASED

product: SuperCans

manufacturer : Acme

price : 150

product: CoolDecks

manufacturer : Acme

price : 599

graph algorithms
Graph Algorithms

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

Node theMaster = …

Node theDoctor = …

intmaxDepth = 5;

PathFinder<Path> shortestPathFinder = GraphAlgoFactory.shortestPath(Traversal.expanderForAllTypes(), maxDepth);

Path shortestPath=

shortestPathFinder.findSinglePath(theDoctor, theMaster);

path finding
Path finding

Find all the episodes where Rose Tyler fought the Daleks

path finder code
Path finder code

algo

Node rose = ...

Node daleks = ...

PathFinder<Path> pathFinder = GraphAlgoFactory.pathsWithLength(Traversal.expanderForTypes(DoctorWhoUniverse.APPEARED_IN, Direction.BOTH), 2);

Iterable<Path> paths = pathFinder.findAllPaths(rose, daleks);

constraints

fixed path length

slide26

!PURCHASED

product: CoolDecks

manufacturer : Acme

age: < 40

PURCHASED

product: SuperCans

manufacturer : Acme

why graph matching
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
setting up and matching a pattern
Setting up and matching a pattern

final PatternNodetheDoctor = new PatternNode();

theDoctor.setAssociation(universe.theDoctor());

final PatternNodeanEpisode = new PatternNode();

anEpisode.addPropertyConstraint("title", CommonValueMatchers.has());

anEpisode.addPropertyConstraint("episode", CommonValueMatchers.has());

final PatternNodeaDoctorActor = new PatternNode();

aDoctorActor.createRelationshipTo(theDoctor, DoctorWhoUniverse.PLAYED);

aDoctorActor.createRelationshipTo(anEpisode, DoctorWhoUniverse.APPEARED_IN);

aDoctorActor.addPropertyConstraint("actor", CommonValueMatchers.has());

final PatternNodetheCybermen = new PatternNode();

theCybermen.setAssociation(universe.speciesIndex.get("species", "Cyberman").getSingle());

theCybermen.createRelationshipTo(anEpisode, DoctorWhoUniverse.APPEARED_IN);

theCybermen.createRelationshipTo(theDoctor, DoctorWhoUniverse.ENEMY_OF);

PatternMatchermatcher = PatternMatcher.getMatcher();

final Iterable<PatternMatch> matches = matcher.match(theDoctor, universe.theDoctor());

slide31

http://www.561studios.com/blog/wp-content/uploads/2010/07/commonsense.jpghttp://www.561studios.com/blog/wp-content/uploads/2010/07/commonsense.jpg

questions

Questions?

Community: http://neo4j.org

Koans: https://github.com/jimwebber/neo4j-tutorial

Me: @jimwebber, jim@neotechnology.com