Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Próxima SlideShare
Cargando en…5
×

# Application Modeling with Graph Databases

7.609 visualizaciones

Publicado en: Tecnología, Empresariales
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Sé el primero en comentar

### Application Modeling with Graph Databases

1. Application Modelingwith Graph Databases http://joind.in/6694
2. @josh_adell• Software developer: PHP, Javascript, SQL• http://www.dunnwell.com• http://blog.everymansoftware.com• http://github.com/jadell/neo4jphp• http://frostymug.herokuapp.com
3. The Problem
4. The Solution?> -- First degree> SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_titleFROM cast WHERE actor_name=Kevin Bacon)> -- Second degree> SELECT actor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_titleFROM 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_titleFROM cast WHERE actor_name IN (SELECT actor_name FROM cast WHERE movie_title IN(SELECT DISTINCT movie_title FROM cast WHERE actor_name IN (SELECTactor_name FROM cast WHERE movie_title IN (SELECT DISTINCT movie_title FROMcast WHERE actor_name=Kevin Bacon))))
5. The TruthRelational databases arent very good with relationships Data RDBMs
6. RDBs Use Set Math
7. Try again?
8. Right Tool for the Job =
9. 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.
10. Graphs are Everywhere
11. Relational Databases are Graphs!
12. Everything is connected
13. Some Graph Use Cases• Social networking• Manufacturing• Map directions• Geo-spatial algorithms• Fraud detection• Multi-tenancy• Dependency mapping• Bioinformatics• Natural language processing
14. Graphs are "Whiteboard-Friendly" Nouns => nodes, Verbs => relationships
15. Back to BaconSTART s=node:actors(name="Keanu Reeves"), e=node:actors(name="Kevin Bacon")MATCH p = shortestPath( s-[*]-e )RETURN p, length(p) http://tinyurl.com/c65d99w
16. ACL• Users can belong to groups• Groups can belong to groups• Groups and users have permissions on objects o read o write o denied
17. START u=node:users(name="User 3")MATCH u-[:belongs_to*]->gRETURN g http://tinyurl.com/cyn3rkx
18. START u=node:users(name="User 2"), o=node:objects(name="Home")MATCH u-[:belongs_to*0..]->g, g-[:can_read]->oRETURN g http://tinyurl.com/dx7onro
19. START u=node:users(name="User 3"), o=node:objects(name="Users 1 Blog")MATCH u-[:belongs_to*0..]->g, g-[:can_read]->o, u-[d?:denied*]->oWHERE d is nullRETURN g http://tinyurl.com/bwtyhvt
20. Real Life Example• Companies have brands, locations, location groups• Brands have locations, location groups• Location groups have locations
21. START c=node:companies(name="Company 1")MATCH c-[:HAS*]->lWHERE l.type = locationRETURN l ORDER BY l.name http://tinyurl.com/cxm4heh
22. START b=node:brands(name="Brand 1")MATCH b<-[:HAS*]-c-[:HAS*]->l<-[h?:HAS*]-bWHERE h IS NULL AND l.type=locationRETURN l ORDER BY l.name http://tinyurl.com/cl537w6
23. Tweet @chicken_techwe should be using graph dbs!
24. But Wait...Theres More!• Mutating Cypher (insert, update)• Indexing (auto, full-text, spatial)• Batches and Transactions• Embedded (for JVM) or REST
25. Where fore art thou, RDB?• Aggregation• Ordered data• Truly tabular data• Few or clearly defined relationships
26. Questions?