ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Introduction to Graph Databases Josh Adell <josh.adell@gmail.com> 20110806
Who am I? Software developer:?PHP, Javascript, SQL http://www.dunnwell.com Fan of using the right tool for the job
The Problem
The Solution? > -- Given &quot;Keanu Reeves&quot; find a connection to &quot;Kevin Bacon&quot; > SELECT ??? FROM cast WHERE ??? +---------------------------------------------------------------------+ | actor_name ? ? ? ? ? ? ? ? | movie_title ? ? ? ? ? ? ? ? ? ? ? ? ? ?| +============================+========================================+ | Jennifer Connelley ? ? ? ? | Higher Learning ? ? ? ? ? ? ? ? ? ? ? ?| +----------------------------+----------------------------------------+ | Laurence Fishburne ? ? ? ? | Mystic River ? ? ? ? ? ? ? ? ? ? ? ? ? | +----------------------------+----------------------------------------+ | Laurence Fishburne ? ? ? ? | Higher Learning ? ? ? ? ? ? ? ? ? ? ? ?| +----------------------------+----------------------------------------+ | Kevin Bacon ? ? ? ? ? ? ? ?| Mystic River ? ? ? ? ? ? ? ? ? ? ? ? ? | +----------------------------+----------------------------------------+ | Keanu Reeves ? ? ? ? ? ? ? | The Matrix ? ? ? ? ? ? ? ? ? ? ? ? ? ? | +----------------------------+----------------------------------------+ | Laurence Fishburne ? ? ? ? | The Matrix ? ? ? ? ? ? ? ? ? ? ? ? ? ? | +----------------------------+----------------------------------------+
Find Every Actor at Each Degree > -- First degree > SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name='Kevin Bacon') > -- Second degree > SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name IN (SELECT actor_name?FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name='Kevin Bacon'))) > -- Third degree > SELECT actor_name FROM cast WHERE movie_title IN(SELECT DISTINCT movie_title FROM cast WHERE actor_name IN (SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name IN (SELECT actor_name?FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name='Kevin Bacon'))))
The Truth Relational databases aren't very good with relationsh ips Data RDBMs
The Real Problem Finding relationships across multiple degrees of separation ? ?  ...and across multiple data types ? ?  ...and where you don't even know there is a relationship
The Real Solution
Graph Examples
Relational Databases are Graphs!
Some Graph Use Cases Social networking Manufacturing Mapping and Geolocation Bioinformatics Fraud detection Multi-tenancy
Modelling a Domain with Graphs Graphs are &quot;whiteboard-friendly&quot; Nouns become nodes Verbs become relationships Properties are adjectives and adverbs
Graph Mining Paths Traversals Ad-hoc Queries
New Solution to the Bacon Problem $keanu = $actorIndex->find('name', 'Keanu Reeves'); $kevin =?$actorIndex->find('name', 'Kevin Bacon'); $path = $keanu->findPathTo($kevin);
Cypher &quot;What to find&quot; vs. &quot;How to find&quot; // Find all the directors who have directed a movie scored by John Williams // that starred Kevin Bacon START actor=(actors, 'Kevin Bacon'), composer=(compsers, 'John Williams') MATCH  (actor)-[:IN]->(movie)<-[:DIRECTED]-(director), ? ? ?  (movie)<-[:SCORED]-(composer) RETURN director
Are RDBs Useful At All? Aggregation Ordered data Truly tabular data Few or clearly defined relationships
Neo Technologies http://neo4j.org Embedded in Java applications Standalone server via REST Plugins: spatial, lucene, rdf Others: Tinkerpop OrientDB
Questions?
Resources http://neo4j.org http://docs.neo4j.org http://www.youtube.com/watch?v=UodTzseLh04 Emil Eifrem (Neo Tech. CEO) webinar Check out around the 54 minute mark http://github.com/jadell/Neo4jPHP http://joshadell.com [email_address] @josh_adell Google+, Facebook, LinkedIn

More Related Content

Similar to Introduction to Graph Databases (10)

Graph Databases
Graph DatabasesGraph Databases
Graph Databases
Josh Adell
?
Microdata, Authorship and Semantic HTML - Ruth Cheesley - J and Beyond 2013
Microdata, Authorship and Semantic HTML - Ruth Cheesley - J and Beyond 2013Microdata, Authorship and Semantic HTML - Ruth Cheesley - J and Beyond 2013
Microdata, Authorship and Semantic HTML - Ruth Cheesley - J and Beyond 2013
Ruth Cheesley
?
Ruth Cheesley - Joomla!Day Kenya - Microdata, Authorship, and why you can't a...
Ruth Cheesley - Joomla!Day Kenya - Microdata, Authorship, and why you can't a...Ruth Cheesley - Joomla!Day Kenya - Microdata, Authorship, and why you can't a...
Ruth Cheesley - Joomla!Day Kenya - Microdata, Authorship, and why you can't a...
Ruth Cheesley
?
Dropping ACID with MongoDB
Dropping ACID with MongoDBDropping ACID with MongoDB
Dropping ACID with MongoDB
kchodorow
?
Ruth Cheesley - Joomla!Day Spain - Microdata and Semantic Search
Ruth Cheesley - Joomla!Day Spain - Microdata and Semantic SearchRuth Cheesley - Joomla!Day Spain - Microdata and Semantic Search
Ruth Cheesley - Joomla!Day Spain - Microdata and Semantic Search
Ruth Cheesley
?
Freebasing for Fun and Enhancement
Freebasing for Fun and EnhancementFreebasing for Fun and Enhancement
Freebasing for Fun and Enhancement
MrDys
?
Pick-a-Plex App: The Pinnacle of Cinema Experiences
Pick-a-Plex App: The Pinnacle of Cinema ExperiencesPick-a-Plex App: The Pinnacle of Cinema Experiences
Pick-a-Plex App: The Pinnacle of Cinema Experiences
Flatiron School
?
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniter
CodeIgniter Conference
?
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
Jeremy Coates
?
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Michael Wales
?
Microdata, Authorship and Semantic HTML - Ruth Cheesley - J and Beyond 2013
Microdata, Authorship and Semantic HTML - Ruth Cheesley - J and Beyond 2013Microdata, Authorship and Semantic HTML - Ruth Cheesley - J and Beyond 2013
Microdata, Authorship and Semantic HTML - Ruth Cheesley - J and Beyond 2013
Ruth Cheesley
?
Ruth Cheesley - Joomla!Day Kenya - Microdata, Authorship, and why you can't a...
Ruth Cheesley - Joomla!Day Kenya - Microdata, Authorship, and why you can't a...Ruth Cheesley - Joomla!Day Kenya - Microdata, Authorship, and why you can't a...
Ruth Cheesley - Joomla!Day Kenya - Microdata, Authorship, and why you can't a...
Ruth Cheesley
?
Dropping ACID with MongoDB
Dropping ACID with MongoDBDropping ACID with MongoDB
Dropping ACID with MongoDB
kchodorow
?
Ruth Cheesley - Joomla!Day Spain - Microdata and Semantic Search
Ruth Cheesley - Joomla!Day Spain - Microdata and Semantic SearchRuth Cheesley - Joomla!Day Spain - Microdata and Semantic Search
Ruth Cheesley - Joomla!Day Spain - Microdata and Semantic Search
Ruth Cheesley
?
Freebasing for Fun and Enhancement
Freebasing for Fun and EnhancementFreebasing for Fun and Enhancement
Freebasing for Fun and Enhancement
MrDys
?
Pick-a-Plex App: The Pinnacle of Cinema Experiences
Pick-a-Plex App: The Pinnacle of Cinema ExperiencesPick-a-Plex App: The Pinnacle of Cinema Experiences
Pick-a-Plex App: The Pinnacle of Cinema Experiences
Flatiron School
?
Writing Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniterWriting Friendly libraries for CodeIgniter
Writing Friendly libraries for CodeIgniter
CodeIgniter Conference
?
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
Jeremy Coates
?
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Michael Wales
?

Recently uploaded (20)

AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
David Brossard
?
Scalable Multi-Agent AI with AutoGen by Udai
Scalable Multi-Agent AI with AutoGen by UdaiScalable Multi-Agent AI with AutoGen by Udai
Scalable Multi-Agent AI with AutoGen by Udai
Udaiappa Ramachandran
?
STARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to PonderSTARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to Ponder
anupriti
?
Why Outsource Accounting to India A Smart Business Move!.pdf
Why Outsource Accounting to India A Smart Business Move!.pdfWhy Outsource Accounting to India A Smart Business Move!.pdf
Why Outsource Accounting to India A Smart Business Move!.pdf
anjelinajones6811
?
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
DianaGray10
?
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI
?
Recruiting Tech: A Look at Why AI is Actually OG
Recruiting Tech: A Look at Why AI is Actually OGRecruiting Tech: A Look at Why AI is Actually OG
Recruiting Tech: A Look at Why AI is Actually OG
Matt Charney
?
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing EnvironmentsAutomated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Pablo G¨®mez Abajo
?
Research Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research processResearch Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research process
HeilaPienaar
?
State_of_AI_Transformation in Germany.pdf
State_of_AI_Transformation in Germany.pdfState_of_AI_Transformation in Germany.pdf
State_of_AI_Transformation in Germany.pdf
VaradRajanKrishna
?
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
?
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
jackalen173
?
Getting the Best of TrueDEM ¨C April News & Updates
Getting the Best of TrueDEM ¨C April News & UpdatesGetting the Best of TrueDEM ¨C April News & Updates
Getting the Best of TrueDEM ¨C April News & Updates
panagenda
?
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptxPackaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
mohayyudin7826
?
Innovative Web Design | Malachite Technologies
Innovative Web Design | Malachite TechnologiesInnovative Web Design | Malachite Technologies
Innovative Web Design | Malachite Technologies
malachitetechnologie1
?
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
DOCOMO Innovations, Inc.
?
Least Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role PermissionsLeast Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role Permissions
Chris Wahl
?
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN NB-IoT LTE cat.M1ÉÌÆ·¥ê¥¹¥È
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN  NB-IoT  LTE cat.M1ÉÌÆ·¥ê¥¹¥ÈDragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN  NB-IoT  LTE cat.M1ÉÌÆ·¥ê¥¹¥È
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN NB-IoT LTE cat.M1ÉÌÆ·¥ê¥¹¥È
CRI Japan, Inc.
?
Columbia Weather Systems - Product Overview
Columbia Weather Systems - Product OverviewColumbia Weather Systems - Product Overview
Columbia Weather Systems - Product Overview
Columbia Weather Systems
?
A General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithmsA General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithms
Buhwan Jeong
?
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
AuthZEN The OpenID Connect of Authorization - Gartner IAM EMEA 2025
David Brossard
?
Scalable Multi-Agent AI with AutoGen by Udai
Scalable Multi-Agent AI with AutoGen by UdaiScalable Multi-Agent AI with AutoGen by Udai
Scalable Multi-Agent AI with AutoGen by Udai
Udaiappa Ramachandran
?
STARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to PonderSTARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to Ponder
anupriti
?
Why Outsource Accounting to India A Smart Business Move!.pdf
Why Outsource Accounting to India A Smart Business Move!.pdfWhy Outsource Accounting to India A Smart Business Move!.pdf
Why Outsource Accounting to India A Smart Business Move!.pdf
anjelinajones6811
?
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
SAP Automation with UiPath: Solution Accelerators and Best Practices - Part 6...
DianaGray10
?
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI: How Much Does an XXX AI Porn Generator Cost in 2025
Sugarlab AI
?
Recruiting Tech: A Look at Why AI is Actually OG
Recruiting Tech: A Look at Why AI is Actually OGRecruiting Tech: A Look at Why AI is Actually OG
Recruiting Tech: A Look at Why AI is Actually OG
Matt Charney
?
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing EnvironmentsAutomated Engineering of Domain-Specific Metamorphic Testing Environments
Automated Engineering of Domain-Specific Metamorphic Testing Environments
Pablo G¨®mez Abajo
?
Research Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research processResearch Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research process
HeilaPienaar
?
State_of_AI_Transformation in Germany.pdf
State_of_AI_Transformation in Germany.pdfState_of_AI_Transformation in Germany.pdf
State_of_AI_Transformation in Germany.pdf
VaradRajanKrishna
?
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
?
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
Fast Screen Recorder v2.1.0.11 Crack Updated [April-2025]
jackalen173
?
Getting the Best of TrueDEM ¨C April News & Updates
Getting the Best of TrueDEM ¨C April News & UpdatesGetting the Best of TrueDEM ¨C April News & Updates
Getting the Best of TrueDEM ¨C April News & Updates
panagenda
?
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptxPackaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
mohayyudin7826
?
Innovative Web Design | Malachite Technologies
Innovative Web Design | Malachite TechnologiesInnovative Web Design | Malachite Technologies
Innovative Web Design | Malachite Technologies
malachitetechnologie1
?
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...Automating Behavior-Driven Development: Boosting Productivity with Template-D...
Automating Behavior-Driven Development: Boosting Productivity with Template-D...
DOCOMO Innovations, Inc.
?
Least Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role PermissionsLeast Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role Permissions
Chris Wahl
?
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN NB-IoT LTE cat.M1ÉÌÆ·¥ê¥¹¥È
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN  NB-IoT  LTE cat.M1ÉÌÆ·¥ê¥¹¥ÈDragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN  NB-IoT  LTE cat.M1ÉÌÆ·¥ê¥¹¥È
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN NB-IoT LTE cat.M1ÉÌÆ·¥ê¥¹¥È
CRI Japan, Inc.
?
A General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithmsA General introduction to Ad ranking algorithms
A General introduction to Ad ranking algorithms
Buhwan Jeong
?

Introduction to Graph Databases

  • 1. Introduction to Graph Databases Josh Adell <josh.adell@gmail.com> 20110806
  • 2. Who am I? Software developer:?PHP, Javascript, SQL http://www.dunnwell.com Fan of using the right tool for the job
  • 4. The Solution? > -- Given &quot;Keanu Reeves&quot; find a connection to &quot;Kevin Bacon&quot; > SELECT ??? FROM cast WHERE ??? +---------------------------------------------------------------------+ | actor_name ? ? ? ? ? ? ? ? | movie_title ? ? ? ? ? ? ? ? ? ? ? ? ? ?| +============================+========================================+ | Jennifer Connelley ? ? ? ? | Higher Learning ? ? ? ? ? ? ? ? ? ? ? ?| +----------------------------+----------------------------------------+ | Laurence Fishburne ? ? ? ? | Mystic River ? ? ? ? ? ? ? ? ? ? ? ? ? | +----------------------------+----------------------------------------+ | Laurence Fishburne ? ? ? ? | Higher Learning ? ? ? ? ? ? ? ? ? ? ? ?| +----------------------------+----------------------------------------+ | Kevin Bacon ? ? ? ? ? ? ? ?| Mystic River ? ? ? ? ? ? ? ? ? ? ? ? ? | +----------------------------+----------------------------------------+ | Keanu Reeves ? ? ? ? ? ? ? | The Matrix ? ? ? ? ? ? ? ? ? ? ? ? ? ? | +----------------------------+----------------------------------------+ | Laurence Fishburne ? ? ? ? | The Matrix ? ? ? ? ? ? ? ? ? ? ? ? ? ? | +----------------------------+----------------------------------------+
  • 5. Find Every Actor at Each Degree > -- First degree > SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name='Kevin Bacon') > -- Second degree > SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name IN (SELECT actor_name?FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name='Kevin Bacon'))) > -- Third degree > SELECT actor_name FROM cast WHERE movie_title IN(SELECT DISTINCT movie_title FROM cast WHERE actor_name IN (SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name IN (SELECT actor_name?FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROM cast WHERE actor_name='Kevin Bacon'))))
  • 6. The Truth Relational databases aren't very good with relationsh ips Data RDBMs
  • 7. The Real Problem Finding relationships across multiple degrees of separation ? ? ...and across multiple data types ? ? ...and where you don't even know there is a relationship
  • 11. Some Graph Use Cases Social networking Manufacturing Mapping and Geolocation Bioinformatics Fraud detection Multi-tenancy
  • 12. Modelling a Domain with Graphs Graphs are &quot;whiteboard-friendly&quot; Nouns become nodes Verbs become relationships Properties are adjectives and adverbs
  • 13. Graph Mining Paths Traversals Ad-hoc Queries
  • 14. New Solution to the Bacon Problem $keanu = $actorIndex->find('name', 'Keanu Reeves'); $kevin =?$actorIndex->find('name', 'Kevin Bacon'); $path = $keanu->findPathTo($kevin);
  • 15. Cypher &quot;What to find&quot; vs. &quot;How to find&quot; // Find all the directors who have directed a movie scored by John Williams // that starred Kevin Bacon START actor=(actors, 'Kevin Bacon'), composer=(compsers, 'John Williams') MATCH (actor)-[:IN]->(movie)<-[:DIRECTED]-(director), ? ? ? (movie)<-[:SCORED]-(composer) RETURN director
  • 16. Are RDBs Useful At All? Aggregation Ordered data Truly tabular data Few or clearly defined relationships
  • 17. Neo Technologies http://neo4j.org Embedded in Java applications Standalone server via REST Plugins: spatial, lucene, rdf Others: Tinkerpop OrientDB
  • 19. Resources http://neo4j.org http://docs.neo4j.org http://www.youtube.com/watch?v=UodTzseLh04 Emil Eifrem (Neo Tech. CEO) webinar Check out around the 54 minute mark http://github.com/jadell/Neo4jPHP http://joshadell.com [email_address] @josh_adell Google+, Facebook, LinkedIn

Editor's Notes

  • #3: * graph db usage poll
  • #4: * Six degrees game * Relational databases can&apos;t easily answer certain types of questions
  • #5: * first pass using a relational database * cast table: actor_name, movie_title * hard to visualize the solution * In order to do this, you need to do multiple passes or joins
  • #6: * Each degree adds a join * Increases complexity * Decreases performance * Stop when the actor you&apos;re looking for is in the list
  • #7: * this problem highlights the ugly truth about RDBs * they weren&apos;t designed to handle these types of problems. * arbitrary path query * RDB relationships join data, but are not data in themselves * Set math * Gather everything in the set that matches these criteria, then tell me if this thing is in the set * 1 set, no problem * 2nd set no problem * 3rd set not related to 1st * 4th not related to 2nd * 5th related to 1st and 4th * etc. * Relationships are only available between overlapping sets
  • #8: * disjoint sets
  • #9: * Graphs * Not X-Y * Computer Science definition of graphs * A graph is an ordered pair? G = (V, E) ?where V is a set of? vertices ?and E is a set of? edges , which are?pairs of?vertices. * Node : vertex * Relationship : edge * Property : meta-datum attached to a node or relationship * Nodes can have arbitrary properties * Relationships are first-class citizens Have a type Have properties Have a direction Domain semantics Traversable in any direction * This is how graph dbs solve the problems that RDBs can&apos;t * Path : an ordered list of nodes and relationships * Paths are found using traversal algorithms
  • #10: * Tree data-structures * Networks * Maps * vehicles on streets == packets through network * Relational databases are graphs!
  • #11: * Make each record a node * Make every foreign key a relationship * RDB indexes are usually stored in a tree structure * Trees are graphs * Why not use RDBs? * The trouble with RDBs is how they are stored in memory and queried ? * Require a translation step from memory blocks to graph structure * Relationships not first-class citizens * Many problem domains map poorly to rows/tables
  • #12: * Big Data ** billions of nodes and relationships in a single instance * &amp;quot;Internet of Things&amp;quot; buzzword * Social networking - friends of friends of friends of friends * Assembly/Manufacturing - 1 widget contains 3 gadgets each contain 2 gizmos * Map directions - starting at my house find a route to the office that goes past the pub * Multi-tenancy - root node per tenant * all queries start at root * No overlap between graphs = no accidental data spillage * Fraud: track transactions back to origination * Pretty much anything that can be drawn on a whiteboard
  • #13: * Example: retail system * Customer makes Order * Store sells Order * Order contains Items * Supplier supplied Items * Customer rates Items * Did this customer rank supplier X highly? * Which suppliers sell the highest rated items? * Does item A get rated higher when ordered with Item B? * All can be answered with RDBs as well * Not as elegant * Not as performant
  • #14: * This is where the power of graph dbs comes from * Paths - find any relationship chain between A and B * Kevin Bacon example, known start and end * Traversal - filter out paths that don&apos;t meet criteria * Complex path finding, base next decision on existing path from start to current position * Define path-finding (prune) and result filtering functions * Queries - Here is what I want, find it however you can * SPARQL, Gremlin, Cypher
  • #15: * Actors are nodes * Movies are nodes * Relationship: Actor is IN a movie * pseudo-code shortened for brevity * Compare to degree selection join queries
  • #16: * Cypher is &amp;quot;what to find&amp;quot; * describe the &amp;quot;shape&amp;quot; of the thing you&apos;re looking for * Very white-board friendly * Pros: easy to understand, query looks like domain model * Cons: not as powerful, not fully featured (YET) * result set is an array of arrays?
  • #17: * RDBs are really good at data aggregation * Set math, duh * Have to traverse the whole graph in order to do aggregation * Truly tabular means not a lot of relationships between the data types
  • #18: * billions of nodes and relationships in a single instance * cluster replication * transactions * native bindings for Ruby, Python, and language that can run in JVM * Licensing