4. Dado el mapa de Königsberg, con el río Pregolya dividiendo
el plano en cuatro regiones distintas, que están unidas a
través de los siete puentes,
¿es posible dar un paseo comenzando desde cualquiera de
estas regiones, pasando por todos los puentes, recorriendo
sólo una vez cada uno, y regresando al mismo punto de
partida?
18. class Client < ActiveRecord::Base
has_one :address
has_many :orders
has_and_belongs_to_many :roles
end
19. DesVentajas de BD Relacionales
Fricción!
Interoperabilidad
Adaptación al cambio
Interoperabilidad
Escalabilidad
No está destinada para ciertos escenarios
22. MySQL vs Neo4j
Profundidad Tiempo MySQL(s) Tiempo Neo4j (s)
Nº Resultados
2
3
0.016
30.267
0.01
0.168
~2500
~110,000
4
1543.505
1.359
~600,000
5
No Acaba
2.132
~800,000
* Neo4J in Action
42. START startNode=node:node_auto_index(name = ‘Sol'),
endNode=node:node_auto_index(name = ‘Cuzco')
MATCH p = (startNode)-[rels:CONNECTED_TO]->(endNode)
RETURN p AS shortestPath,
reduce(weight=0, r in rels: weight + r.weight) as tWeight
ORDER BY tWeight ASC
LIMIT 1
47. Red social de cine
Sigue
User
User
Puntúa
{nota}
Actua en
Film
Actor
Dirige
Director
48. Red social de cine
START fran=node:Persona(name='Fran'),
film=node:Peliculas(title=‘Pulp Fiction')
MATCH fran-[or:PUNTUA]->film<-[:PUNTUA]-otro_user-[r:PUNTUA]->otras_pelis
RETURN distinct otras_pelis.title;
49. Red social de cine
Puntúa
{nota}
Puntúa
{nota}
Film
Film
User 1
Fran
User 2
Puntúa
{nota}
Film
PF
Puntúa
{nota}
Puntúa
{nota}
50. Red social de cine
START fran=node:Persona(name='Fran'),
film=node:Peliculas(title=‘Pulp Fiction')
MATCH fran-[or:PUNTUA]->film<-[:PUNTUA]-otro_user-[r:PUNTUA]->otras_pelis
WHERE or.stars = r.stars
RETURN distinct otras_pelis.title;
51. Red social de cine
START fran=node:Persona(name='Fran'),
film=node:Peliculas(title=‘Pulp Fiction')
MATCH fran-[or:PUNTUA]->film<-[:PUNTUA]-otro_user-[r:PUNTUA]->otras_pelis,
otro_user-[:SIGUE]-fran
WHERE or.stars = r.stars
RETURN distinct otras_pelis.title;
52. Red social de cine
Puntúa
{nota}
Sigue
User 1
Puntúa
{nota}
Fran
Puntúa
{nota}
Film
PF
Film
53. Red social de cine
START tarantino=node:Persona(name='Quentin Tarantino')
MATCH tarantino-[:DIRIGE]->peli<-[:ACTUA_EN]-tarantino
RETURN movie.title;
!
54. Red social de cine
Actua en
Film
Actor
Dirige
Director
55. Red social de cine
Ahora se deben poder categorizar las películas
56. Red social de cine
Genero
Genero
Pertenece_a
Pertenece_a
SubGenero
SubGenero
Pertenece_a
Pertenece_a
Film
57. Red social de cine
START fran=node:Persona(name='Fran'),
film=node:Peliculas(title=‘Pulp Fiction')
MATCH fran-[or:PUNTUA]->film<-[:PUNTUA]-otro_user-[r:PUNTUA]->otras_pelis,
film-[:PERTENECE:*3]->genero<-[:PERTENECE]-otras_pelis
WHERE or.stars = r.stars
RETURN distinct otras_pelis.title;
58. Instead of just picking a relational database
because everyone does, we need to
understand the nature of the data we’re
storing and how we want to manipulate it.
Martin Fowler