Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Application Modeling
with Graph Databases
@josh_adell
http://www.servicetrade.com
http://blog.everymansoftware.com
http://github.com/jadell/neo4jphp

https://joind....
The Problem
The Solution?
> -- First degree
> SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title
FROM cast ...
The Truth
Relational databases aren't very good with relationships

Data

RDBMs
Try again?
Warning: Computer Science Ahead
A graph is an ordered pair G = (V, E)
where V is a set of vertices and
E is a set of edges...
Property Graph
Nodes have properties and labels
Relationships have properties, a type and direction
Relationships are firs...
Graphs are Everywhere
Relational Databases are Graphs!
Everything is connected
Modeling "Whiteboard-Friendly"

Nouns => nodes, Verbs => relationships
Back to Bacon

MATCH p = shortestPath( (r:Actor) - [*] - (b:Actor) )
WHERE r.name=”Keanu Reeves” AND b.name=”Kevin Bacon”
...
Social
MATCH
(:Person {name:"Josh"})-[:FRIEND_OF]-(p:Person),
(m:Movie)
WHERE NOT
(p)-[:HAS_WATCHED]->(m)
RETURN COUNT(p) ...
But Wait...There's More!
Mutating (insert, update ~ create, merge)
Indexing (auto, full-text, spatial)
Batches and Transac...
Where fore art thou, RDB?
Aggregation
Ordered data
Truly tabular data
Few or clearly defined relationships
Questions?
Resources
● http://github.com/jadell/neo4jphp
● http://neo4j.org
● Jim Webber - A Little Graph Theory for the Busy Develop...
Application modelling with graph databases
Upcoming SlideShare
Loading in …5
×

Application modelling with graph databases

4,998 views

Published on

Applications are built around domain and business concepts. As developers, we model these concepts and their relationships all the time in our heads, on whiteboards, and in code. Then we perform mental gymnastics translating objects and relationships into tables, rows and columns. Wouldn't it be better if our data storage thought the same way we do? This talk will describe a few types of problems that relational databases and many contemporary NOSQL solutions have trouble modeling, and how graph databases are a solution to those problems. Along the way, attendees will be introduced to the graph database Neo4j, will see how to interact with it via the Cypher query language, and learn how they can start modeling their own application domains as graphs.

Published in: Technology
  • Be the first to comment

Application modelling with graph databases

  1. 1. Application Modeling with Graph Databases
  2. 2. @josh_adell http://www.servicetrade.com http://blog.everymansoftware.com http://github.com/jadell/neo4jphp https://joind.in/10430
  3. 3. The Problem
  4. 4. The Solution? > -- 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'))))
  5. 5. The Truth Relational databases aren't very good with relationships Data RDBMs
  6. 6. Try again?
  7. 7. Warning: Computer Science Ahead 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 in V. If vertex pairs in E are ordered, the graph is directed.
  8. 8. Property Graph Nodes have properties and labels Relationships have properties, a type and direction Relationships are first-class entities Queried just like Nodes Indexes Unique constraints new in Neo4j 2.0!
  9. 9. Graphs are Everywhere
  10. 10. Relational Databases are Graphs!
  11. 11. Everything is connected
  12. 12. Modeling "Whiteboard-Friendly" Nouns => nodes, Verbs => relationships
  13. 13. Back to Bacon MATCH p = shortestPath( (r:Actor) - [*] - (b:Actor) ) WHERE r.name=”Keanu Reeves” AND b.name=”Kevin Bacon” RETURN p, LENGTH(p)/2
  14. 14. Social MATCH (:Person {name:"Josh"})-[:FRIEND_OF]-(p:Person), (m:Movie) WHERE NOT (p)-[:HAS_WATCHED]->(m) RETURN COUNT(p) as not_seen, m ORDER BY not_seen DESC LIMIT 1
  15. 15. But Wait...There's More! Mutating (insert, update ~ create, merge) Indexing (auto, full-text, spatial) Batches and Transactions Embedded (for JVM) or REST
  16. 16. Where fore art thou, RDB? Aggregation Ordered data Truly tabular data Few or clearly defined relationships
  17. 17. Questions?
  18. 18. Resources ● http://github.com/jadell/neo4jphp ● http://neo4j.org ● Jim Webber - A Little Graph Theory for the Busy Developer ○ http://vimeo.com/76713692 - Jim Webber ● http://joshadell.com ● https://joind.in/10430

×