SlideShare a Scribd company logo
1 of 78
Download to read offline
Introduc)on	
  to	
  graph	
  databases,	
  Neo4j	
  
and	
  Spring	
  Data	
  
	
  
Aleksander	
  M.	
  Stensby	
  
Monokkel	
  A/S	
  
•  Aleksander	
  M.	
  Stensby	
  
•  CEO	
  in	
  Monokkel	
  AS	
  
•  Previously	
  COO	
  in	
  Integrasco	
  AS	
  
•  Working	
  with	
  search	
  and	
  data	
  analysis	
  since	
  2004	
  
www.monokkel.io	
  
•  Daglig	
  leder	
  i	
  Monokkel	
  AS	
  
•  Tidligere	
  COO	
  i	
  Integrasco	
  AS	
  
•  Persistering,	
  Prosessering	
  og	
  Presentasjon	
  av	
  data	
  
Persistence	
  –	
  Processing	
  –	
  PresentaHon	
  
Agenda	
  
•  Intro	
  to	
  graph	
  databases	
  and	
  modelling	
  
	
  
•  Neo4j	
  and	
  Cypher	
  
	
  
•  SpringData	
  Neo4j	
  
RelaHonal	
  databases…	
  
…when	
  it	
  comes	
  to	
  relaHons	
  
RelaHonal	
  databases	
  are	
  awesome	
  
when	
  it	
  comes	
  to	
  aggregaHon	
  of	
  data,	
  
schema	
  mapping	
  and	
  tabular	
  data!	
  
BUT	
  
We	
  have	
  a	
  tendency	
  to	
  force	
  	
  
_all_	
  	
  
our	
  problems	
  into	
  our	
  relaHonal	
  
databases!	
  
Join-­‐hell..	
  
Recursion...	
  
Null-­‐checks...	
  
Polyglot	
  persistence	
  
NoSQL	
  
Not	
  only	
  SQL	
  
NoSQL	
  
•  Key-­‐value	
  stores	
  
– Amazon	
  Dynamo	
  
– Ex:	
  Voldemort,...	
  
•  BigTable	
  clones	
  
– Google’s	
  BigTable	
  
– Ex:	
  Hbase,	
  ...	
  
•  Document	
  databases	
  
– Lotus	
  Notes	
  
– Ex:	
  MongoDB,	
  CouchDB	
  
NoSQL	
  
•  Graph	
  databases	
  
– Euler	
  and	
  graph	
  theory	
  
– Ex:	
  Neo4j,	
  VertexDB,	
  AllegroGraph,	
  
Giraphe,	
  OrientDB,	
  etc...	
  
NoSQL	
  Size	
  
Complexity	
  
Graphs	
  
Document	
  
BigTable	
  
KV	
  
NoSQL	
  Size	
  
Complexity	
  
Graphs	
  
Document	
  
BigTable	
  
KV	
  
90%	
  
Billions	
  of	
  nodes	
  and	
  rela)onships	
  
enough	
  buzzwords…	
  
Friends	
  of	
  friends...	
  
Person	
  
ID	
  
Name	
  
Friends	
  
PersonID	
  
FriendID	
  
Person	
  
ID	
  
Name	
  
Friends	
  
PersonID	
  
FriendID	
  
«Aleks»’s	
  friends	
  
SELECT	
  p1.Person	
  
FROM	
  Person	
  p1	
  JOIN	
  Friends	
  
	
  ON	
  Friends.FriendID	
  =	
  p1.ID	
  
JOIN	
  Person	
  p2	
  
	
  ON	
  Friends.PersonID	
  =	
  p2.ID	
  
WHERE	
  p2.Name=	
  'Aleks'	
  
Person	
  
ID	
  
Name	
  
Friends	
  
PersonID	
  
FriendID	
  
Friends	
  with	
  «Aleks»	
  
SELECT	
  p1.Person	
  
FROM	
  Person	
  p1	
  JOIN	
  Friends	
  
	
  ON	
  Friends.PersonID	
  =	
  p1.ID	
  
JOIN	
  Person	
  p2	
  
	
  ON	
  Friends.FriendID	
  =	
  p2.ID	
  
WHERE	
  p2.Name	
  =	
  'Aleks'	
  
Person	
  
ID	
  
Name	
  
Friends	
  
PersonID	
  
FriendID	
  
«Aleks»’s	
  friends’	
  friends?	
  
SELECT	
  p1.Person	
  AS	
  PERSON,	
  p2.Person	
  AS	
  FRIEND_OF_FRIEND	
  
FROM	
  Friends	
  v1	
  JOIN	
  Person	
  p1	
  
	
  ON	
  v1.PersonID	
  =	
  p1.ID	
  
JOIN	
  Friends	
  v2	
  
	
  ON	
  v2.FriendID	
  =	
  v1.FriendID	
  
JOIN	
  Person	
  p2	
  
	
  ON	
  v2.FriendID	
  =	
  p2.	
  ID	
  
WHERE	
  p1.Name	
  =	
  'Aleks‘	
  AND	
  v2.FriendID	
  <>	
  p1.ID	
  
Source:	
  Neo4j	
  in	
  AcHon
1,000,000	
  persons	
  
Depth	
   RDBMS	
   Neo4j	
   Records	
  
2	
   0.016	
   0.01	
   ~	
  2500	
  
3	
   30.267	
   0.168	
   ~	
  110,000	
  
4	
   1543.505	
   1.359	
   ~	
  600,000	
  
5	
   DNF	
   2.132	
   ~	
  800,000	
  
A	
  graph	
  database...	
  
•  uses	
  graph	
  structures	
  with	
  
– Nodes	
  
– RelaHonships	
  
– Apributes	
  
	
  
•  to	
  store	
  informaHon!	
  
•  Exellent	
  for	
  relaHonships	
  –	
  but	
  not	
  necessarily	
  
best	
  at	
  aggregaHng	
  data	
  
Graph	
  databases	
  and	
  neo4j	
  
•  Visual	
  –	
  Schema	
  less!	
  	
  
•  Doubly-­‐linked-­‐lists	
  
– each	
  node	
  has	
  a	
  list	
  of	
  incoming	
  and	
  outgoing	
  
relaWonships	
  
	
  
•  Direct	
  lookup	
  =	
  O(1)	
  
A	
  graph	
  stores	
  data	
  in	
  nodes	
  
ALEKS	
   TARJEI	
  
Nodes	
  are	
  connected	
  by	
  relaWonships	
  
FRIENDS_WITH	
  
ALEKS	
   TARJEI	
  
Nodes	
  have	
  aributes	
  
ALEKS	
   TARJEI	
  
Age:	
  29	
  
First	
  Name:	
  Aleksander	
  
Last	
  Name:	
  Stensby	
  
	
  
Age:	
  30	
  
First	
  Name:	
  Tarjei	
  
Last	
  Name:	
  Romtveit	
  
	
  
FRIENDS_WITH	
  
RelaWonships	
  can	
  also	
  have	
  aributes	
  
ALEKS	
   TARJEI	
  
Age:	
  29	
  
First	
  Name:	
  Aleksander	
  
Last	
  Name:	
  Stensby	
  
	
  
Age:	
  30	
  
First	
  Name:	
  Tarjei	
  
Last	
  Name:	
  Romtveit	
  
	
  
FRIENDS_WITH	
  
Since:	
  01.01.2004	
  
RelaWonships	
  can	
  be	
  bi-­‐direcHonal	
  
ALEKS	
   TARJEI	
  
Age:	
  29	
  
First	
  Name:	
  Aleksander	
  
Last	
  Name:	
  Stensby	
  
	
  
Age:	
  30	
  
First	
  Name:	
  Tarjei	
  
Last	
  Name:	
  Romtveit	
  
	
  
FRIENDS_WITH	
  
Since:	
  01.01.2004	
  
FRIENDS_WITH	
  
Since:	
  01.01.2004	
  
ALEKS	
   TARJEI	
  
Age:	
  29	
  
First	
  Name:	
  Aleksander	
  
Last	
  Name:	
  Stensby	
  
	
  
Age:	
  30	
  
First	
  Name:	
  Tarjei	
  
Last	
  Name:	
  Romtveit	
  
	
  
FRIENDS_WITH	
  
Since:	
  01.01.2004	
  
ALEKS	
   TARJEI	
  
Age:	
  29	
  
First	
  Name:	
  Aleksander	
  
Last	
  Name:	
  Stensby	
  
Type:	
  Person	
  
	
  
Age:	
  30	
  
First	
  Name:	
  Tarjei	
  
Last	
  Name:	
  Romtveit	
  
Type:	
  Person	
  
	
  
FRIENDS_WITH	
  
Since:	
  01.01.2004	
  
different	
  types	
  of	
  nodes	
  
Person	
   Person	
  
Sport	
  
Programming	
  language	
  
Drink	
  
Person	
  
Some	
  use	
  cases	
  
•  Social	
  Media	
  
•  RecommendaHons	
  
•  Geo	
  rouHng	
  and	
  logisHcs	
  
•  Access	
  management	
  
•  Network	
  management	
  
•  Finance	
  /	
  Fraud	
  
Neo4j	
  –	
  [IS_A]	
  -­‐>	
  Property	
  Graph	
  
Neo4j	
  2.2.x	
  
•  Currently	
  early	
  access	
  milestone	
  4	
  
•  New	
  page	
  cache	
  -­‐>	
  high	
  concurrency	
  
	
  
•  TransacHonal	
  and	
  batch	
  write	
  performance	
  
•  Cost-­‐Based	
  OpHmizer	
  for	
  Cypher	
  
(node)	
  –	
  [relaHonship]	
  -­‐>	
  (node)	
  
(Aleks)	
  –	
  [FRIENDS_WITH]	
  -­‐>	
  (Tarjei)	
  
Cypher	
  
"Make	
  the	
  simple	
  things	
  simple,	
  and	
  the	
  complex	
  things	
  possible"	
  
Intro	
  to	
  Cypher	
  
•  START	
  
•  MATCH	
  
•  WHERE	
  
•  RETURN	
  
•  CREATE	
  
•  DELETE	
  
•  SET	
  
•  FOREACH	
  
•  WITH	
  
MATCH	
  <papern>	
  	
  
WHERE	
  
RETURN	
  	
  
Describe	
  what	
  you	
  want	
  to	
  retrieve	
  
with	
  PATTERNS	
  
(a)-­‐[r]-­‐>(b)	
  
(Aleks)	
  –	
  [FRIENDS_WITH]	
  -­‐>	
  (Tarjei)	
  
Path	
  depth	
  
(a)-­‐[*]-­‐>(b)	
  
	
  
	
  
START	
  
START	
  n=node(1)	
  
RETURN	
  n	
  
MATCH	
  
MATCH	
  (movie:Movie)	
  
RETURN	
  movie	
  
WHERE	
  
MATCH	
  movie	
  
WHERE	
  move.Htle	
  =	
  ‘Blade	
  Runner'	
  
RETURN	
  movie	
  
START	
  a=node(*)	
  
MATCH	
  (a:Person)	
  
WHERE	
  a.name='Danny	
  DeVito'	
  
RETURN	
  a	
  
START	
  a=node(*)	
  
MATCH	
  (a:Person)	
  
WHERE	
  a.name='Danny	
  DeVito'	
  
RETURN	
  a	
  
START	
  a=node(*)	
  
MATCH	
  (a:Person	
  {name:	
  'Danny	
  DeVito'}	
  )	
  
WHERE	
  a.name='Danny	
  DeVito'	
  
RETURN	
  a	
  
Neo4j	
  2.0.1	
  
Friend	
  of	
  friend...	
  
MATCH	
  (aleks)-­‐[r:KNOWS]-­‐()-­‐[r2:KNOWS]	
  -­‐>(friend_of_friend)	
  
WHERE	
  aleks.firstName=	
  'Aleks'	
  
RETURN	
  friend_of_friend.firstName	
  
Friend	
  of	
  friend...	
  
MATCH	
  (aleks)-­‐[:KNOWS*2..2]-­‐>(friend_of_friend)	
  
WHERE	
  aleks.firstName=	
  'Aleks'	
  
AND	
  NOT	
  (aleks)-­‐[:KNOWS]-­‐>(friend_of_friend)	
  
RETURN	
  friend_of_friend.firstName	
  
hpp://docs.neo4j.org/refcard/2.1.7/	
  
 
	
  
	
  
	
  
	
  
DEMO	
  
	
  
And	
  a	
  whole	
  lot	
  more…	
  
•  Traversals	
  to	
  navigate	
  the	
  graph	
  
•  Traversals	
  idenHfy	
  paths	
  
•  Paths	
  order	
  nodes	
  
•  Cypher	
  parameters	
  
•  Indexes	
  
•  Neo4j	
  embedded,	
  Neo4j	
  REST	
  
•  Neo4j	
  2.x	
  –	
  Labels	
  and	
  automaWc	
  indexes	
  
•  Gremlin	
  (procedural)	
  –	
  Cypher	
  (declaraHve)	
  
•  Enterprise	
  (mulH-­‐instance	
  cluster,	
  online	
  backup)	
  
•  Neo4j	
  SpaWal	
  
Language	
  drivers	
  
Contrib	
  
Intro	
  to	
  SpringData	
  Neo4j	
  
•  SpringData	
  
•  Repositories	
  
•  Quick	
  example	
  
<dependencies>	
  
	
  	
  	
  	
  <dependency>	
  
	
  	
  	
  	
  	
  	
  	
  	
  <groupId>org.springframework.data</groupId>	
  
	
  	
  	
  	
  	
  	
  	
  	
  <arHfactId>spring-­‐data-­‐neo4j</arHfactId>	
  
	
  	
  	
  	
  	
  	
  	
  	
  <version>3.2.2.RELEASE</version>	
  
	
  	
  	
  	
  </dependency>	
  
</dependencies>	
  
neo4j 	
   	
   	
  2.1.7	
  
spring-­‐data-­‐neo4j 	
   	
  3.2.2	
  
spring 	
   	
   	
  4.1.4	
  
SpringData	
  Neo4j	
  Config	
  
@Configuration	
  
@EnableNeo4jRepositories("no.stensby.javabin.neo.repositories")	
  
public	
  class	
  Config	
  extends	
  Neo4jConfiguration	
  {	
  
}	
  
@Autowired	
  
protected	
  Neo4jTemplate	
  template;	
  
SpringData	
  Neo4j	
  Config	
  
@Configuration	
  
@EnableNeo4jRepositories("no.stensby.javabin.neo.repositories")	
  
public	
  class	
  Config	
  extends	
  Neo4jConfiguration	
  {	
  
	
  
	
  public	
  Config	
  (){	
  
	
  	
  	
  	
  	
  	
  	
  	
  setBasePackage("no.stensby.javabin.neo.domain");	
  
	
  	
  	
  	
  }	
  
	
  
}	
  
@Autowired	
  
protected	
  Neo4jTemplate	
  template;	
  
SpringData	
  Neo4j	
  Config	
  
@Bean	
  
GraphDatabaseService	
  graphDatabaseService()	
  {	
  
return	
  new	
  GraphDatabaseFactory().newEmbeddedDatabase("tmp/neo4j");	
  
}	
  
Embedded:	
  
REST:	
  	
  
@Bean	
  
GraphDatabaseService	
  graphDatabaseService()	
  {	
  
return	
  new	
  SpringRestGraphDatabase("http://localhost:7474/db/data");	
  
}	
  
@Bean(destroyMethod	
  =	
  "shutdown")	
  
@Scope(SCOPE_PROTOTYPE)	
  
public	
  GraphDatabaseService	
  graphDatabaseService()	
  {	
  
return	
  new	
  TestGraphDatabaseFactory().newImpermanentDatabase();	
  
}	
  
TEST:	
  	
  
SpringData	
  Neo4j	
  -­‐	
  Domain	
  
@NodeEntity	
  
public	
  class	
  Person	
  {	
  
@GraphId	
  
public	
  Long	
  nodeId;	
  
	
  
@Indexed(unique	
  =	
  true)	
  
public	
  int	
  id;	
  
	
  
public	
  String	
  firstName;	
  
public	
  String	
  lastName;	
  
}	
  
1-­‐1	
  relaHonships	
  
@NodeEntity	
  
public	
  class	
  Address	
  {	
  
	
  
private	
  Country	
  country;	
  
	
  
...	
  
}	
  
1-­‐1	
  relaHonships	
  
@NodeEntity	
  
public	
  class	
  Address	
  {	
  
	
  
@Fetch	
  
private	
  Country	
  country;	
  
	
  
...	
  
}	
  
1-­‐m	
  relaHonships	
  -­‐	
  @RelatedTo	
  
@RelatedTo(type	
  =	
  "ADDRESS")	
  
private	
  Set<Address>	
  addresses	
  =	
  new	
  HashSet<Address>();	
  
@RelatedTo	
  
private	
  Set<Person>	
  venner	
  =	
  new	
  HashSet<Person>	
  ();	
  
m-­‐m	
  relaHonships	
  -­‐	
  @RelatedToVia	
  
@Fetch	
  
@RelatedToVia	
  (type	
  =	
  "ACTS_IN")	
  
Set<Role>	
  roles	
  =	
  new	
  
HashSet<Role>();	
  
@Fetch	
  
@RelatedToVia(type	
  =	
  "ACTS_IN",	
  direction	
  =	
  Direction.INCOMING)	
  	
  
Set<Role>	
  cast	
  =	
  new	
  HashSet<Role>();	
  
Actor	
  Movie	
  
@RelationshipEntity(type	
  =	
  "ACTS_IN")	
  
public	
  class	
  Role	
  {	
  
@GraphId	
  
Long	
  nodeId;	
  
@StartNode	
  
Actor	
  actor;	
  
@EndNode	
  
Movie	
  movie;	
  
Role	
  
SpringData	
  Neo4j	
  -­‐	
  Repositories	
  
GraphRepository<Person>	
  personRepository	
  =	
  template.repositoryFor(Person.class);	
  
@Autowired	
  
Neo4jTemplate	
  template;	
  
SpringData	
  Neo4j	
  -­‐	
  Repositories	
  
public	
  interface	
  PersonRepository	
  extends	
  GraphRepository<Person>{}	
  
@Autowired	
  
PersonRepository	
  repository;	
  
SpringData	
  Neo4j	
  -­‐	
  Repositories	
  
public	
  interface	
  PersonRepository	
  extends	
  GraphRepository<Person>{	
  
	
  
	
  
List<Person>	
  findByFirstName(String	
  firstName);	
  
	
  
}	
  
SpringData	
  Neo4j	
  -­‐	
  Repositories	
  
public	
  interface	
  PersonRepository	
  extends	
  GraphRepository<Person>{	
  
	
  
	
  
List<Person>	
  findByFirstName(String	
  firstName);	
  
	
  
@Query("MATCH	
  (p:Person{firstName:{0}})	
  RETURN	
  p")	
  	
  
List<Person>	
  getPersonWithFirstName	
  (String	
  firstName);	
  
	
  
}	
  
SpringData	
  Neo4j	
  -­‐	
  Repositories	
  
public	
  interface	
  PersonRepository	
  extends	
  GraphRepository<Person>{	
  
	
  
	
  
List<Person>	
  findByFirstName(String	
  firstName);	
  
	
  
@Query("MATCH	
  (p:Person{firstName:{0}})	
  RETURN	
  p")	
  	
  
List<Person>	
  getPersonWithFirstName	
  (String	
  firstName);	
  
	
  
	
  
@Query(	
  "MATCH	
  (p:Person{firstName:{0}})-­‐[:knows]-­‐>friends	
  "	
  +	
  
	
  "	
  RETURN	
  friends")	
  	
  
Iterable<Person>	
  findFriendsOfPerson(String	
  firstName);	
  
	
  
	
  
}	
  
Lessons	
  Learned	
  
•  Be	
  careful	
  with	
  versions	
  and	
  upgrading	
  …	
  
–  Neo	
  1.9.x	
  -­‐>	
  Neo	
  2.x	
  =	
  lots	
  of	
  problems…	
  
–  Lots	
  of	
  breaking	
  changes…	
  
–  Spring	
  Data	
  Neo4j	
  !=	
  Neo4j	
  
	
  
•  Nodes	
  are	
  “first-­‐class”	
  ciHzens	
  in	
  the	
  graph	
  
–  Hyperedges	
  are	
  not	
  supported	
  -­‐>	
  use	
  “event	
  nodes”	
  
	
  
•  AggregaHons	
  are	
  expensive	
  –	
  caching	
  stats	
  on	
  nodes!	
  
•  Unique	
  and	
  expressive	
  relaHonship	
  types	
  
Pi•alls	
  
•  Don’t	
  use	
  the	
  graphid	
  as	
  your	
  ID	
  
•  IniHalize	
  Set	
  
•  Use	
  @Fetch	
  with	
  care	
  
•  Use	
  standard	
  gepers/sepers	
  
•  Be	
  careful	
  with	
  String	
  escaping	
  
InspiraHon	
  
•  Single	
  Malt	
  Scotch	
  Whisky	
  
hpp://gist.neo4j.org/?8139605	
  
	
  
•  Chess	
  Games	
  and	
  PosiWons	
  
hpp://gist.neo4j.org/?6506717	
  
	
  
•  Movie	
  RecommendaWons	
  
hpp://gist.neo4j.org/?8173017	
  
•  Food	
  Recipes	
  RecommendaWon	
  
hpp://gist.neo4j.org/?8731452	
  

More Related Content

What's hot

Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendationsproksik
 
Data modeling with neo4j tutorial
Data modeling with neo4j tutorialData modeling with neo4j tutorial
Data modeling with neo4j tutorialMax De Marzi
 
The openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageThe openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageNeo4j
 
Intro to Neo4j with Ruby
Intro to Neo4j with RubyIntro to Neo4j with Ruby
Intro to Neo4j with RubyMax De Marzi
 
Introduction to Graph Database
Introduction to Graph DatabaseIntroduction to Graph Database
Introduction to Graph DatabaseEric Lee
 
Relational to Graph - Import
Relational to Graph - ImportRelational to Graph - Import
Relational to Graph - ImportNeo4j
 
GraphConnect 2014 SF: From Zero to Graph in 120: Model
GraphConnect 2014 SF: From Zero to Graph in 120: ModelGraphConnect 2014 SF: From Zero to Graph in 120: Model
GraphConnect 2014 SF: From Zero to Graph in 120: ModelNeo4j
 
Designing and Building a Graph Database Application – Architectural Choices, ...
Designing and Building a Graph Database Application – Architectural Choices, ...Designing and Building a Graph Database Application – Architectural Choices, ...
Designing and Building a Graph Database Application – Architectural Choices, ...Neo4j
 
Intro to Cypher
Intro to CypherIntro to Cypher
Intro to CypherNeo4j
 
Windy City DB - Recommendation Engine with Neo4j
Windy City DB - Recommendation Engine with Neo4jWindy City DB - Recommendation Engine with Neo4j
Windy City DB - Recommendation Engine with Neo4jMax De Marzi
 
Neo4j Fundamentals
Neo4j FundamentalsNeo4j Fundamentals
Neo4j FundamentalsMax De Marzi
 
Intro to Graphs and Neo4j
Intro to Graphs and Neo4jIntro to Graphs and Neo4j
Intro to Graphs and Neo4jjexp
 
Neo4J : Introduction to Graph Database
Neo4J : Introduction to Graph DatabaseNeo4J : Introduction to Graph Database
Neo4J : Introduction to Graph DatabaseMindfire Solutions
 
Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1Max De Marzi
 
Family tree of data – provenance and neo4j
Family tree of data – provenance and neo4jFamily tree of data – provenance and neo4j
Family tree of data – provenance and neo4jM. David Allen
 
An Introduction to NOSQL, Graph Databases and Neo4j
An Introduction to NOSQL, Graph Databases and Neo4jAn Introduction to NOSQL, Graph Databases and Neo4j
An Introduction to NOSQL, Graph Databases and Neo4jDebanjan Mahata
 
How Graph Databases efficiently store, manage and query connected data at s...
How Graph Databases efficiently  store, manage and query  connected data at s...How Graph Databases efficiently  store, manage and query  connected data at s...
How Graph Databases efficiently store, manage and query connected data at s...jexp
 
Introducing Neo4j graph database
Introducing Neo4j graph databaseIntroducing Neo4j graph database
Introducing Neo4j graph databaseAmirhossein Saberi
 

What's hot (20)

Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendations
 
Data modeling with neo4j tutorial
Data modeling with neo4j tutorialData modeling with neo4j tutorial
Data modeling with neo4j tutorial
 
The openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageThe openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query Language
 
Intro to Neo4j with Ruby
Intro to Neo4j with RubyIntro to Neo4j with Ruby
Intro to Neo4j with Ruby
 
Introduction to Graph Database
Introduction to Graph DatabaseIntroduction to Graph Database
Introduction to Graph Database
 
Relational to Graph - Import
Relational to Graph - ImportRelational to Graph - Import
Relational to Graph - Import
 
GraphConnect 2014 SF: From Zero to Graph in 120: Model
GraphConnect 2014 SF: From Zero to Graph in 120: ModelGraphConnect 2014 SF: From Zero to Graph in 120: Model
GraphConnect 2014 SF: From Zero to Graph in 120: Model
 
Designing and Building a Graph Database Application – Architectural Choices, ...
Designing and Building a Graph Database Application – Architectural Choices, ...Designing and Building a Graph Database Application – Architectural Choices, ...
Designing and Building a Graph Database Application – Architectural Choices, ...
 
Intro to Cypher
Intro to CypherIntro to Cypher
Intro to Cypher
 
Windy City DB - Recommendation Engine with Neo4j
Windy City DB - Recommendation Engine with Neo4jWindy City DB - Recommendation Engine with Neo4j
Windy City DB - Recommendation Engine with Neo4j
 
Neo4j Fundamentals
Neo4j FundamentalsNeo4j Fundamentals
Neo4j Fundamentals
 
Intro to Graphs and Neo4j
Intro to Graphs and Neo4jIntro to Graphs and Neo4j
Intro to Graphs and Neo4j
 
Graph databases
Graph databasesGraph databases
Graph databases
 
ETL into Neo4j
ETL into Neo4jETL into Neo4j
ETL into Neo4j
 
Neo4J : Introduction to Graph Database
Neo4J : Introduction to Graph DatabaseNeo4J : Introduction to Graph Database
Neo4J : Introduction to Graph Database
 
Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1
 
Family tree of data – provenance and neo4j
Family tree of data – provenance and neo4jFamily tree of data – provenance and neo4j
Family tree of data – provenance and neo4j
 
An Introduction to NOSQL, Graph Databases and Neo4j
An Introduction to NOSQL, Graph Databases and Neo4jAn Introduction to NOSQL, Graph Databases and Neo4j
An Introduction to NOSQL, Graph Databases and Neo4j
 
How Graph Databases efficiently store, manage and query connected data at s...
How Graph Databases efficiently  store, manage and query  connected data at s...How Graph Databases efficiently  store, manage and query  connected data at s...
How Graph Databases efficiently store, manage and query connected data at s...
 
Introducing Neo4j graph database
Introducing Neo4j graph databaseIntroducing Neo4j graph database
Introducing Neo4j graph database
 

Viewers also liked

Understanding Graph Databases with Neo4j and Cypher
Understanding Graph Databases with Neo4j and CypherUnderstanding Graph Databases with Neo4j and Cypher
Understanding Graph Databases with Neo4j and CypherRuhaim Izmeth
 
Cypher Query Language
Cypher Query Language Cypher Query Language
Cypher Query Language graphdevroom
 
Intro to Cypher
Intro to CypherIntro to Cypher
Intro to Cypherjexp
 
Introduction to Neo4j and .Net
Introduction to Neo4j and .NetIntroduction to Neo4j and .Net
Introduction to Neo4j and .NetNeo4j
 
Neo4j -[:LOVES]-> Cypher
Neo4j -[:LOVES]-> CypherNeo4j -[:LOVES]-> Cypher
Neo4j -[:LOVES]-> Cypherjexp
 

Viewers also liked (6)

Cypher
CypherCypher
Cypher
 
Understanding Graph Databases with Neo4j and Cypher
Understanding Graph Databases with Neo4j and CypherUnderstanding Graph Databases with Neo4j and Cypher
Understanding Graph Databases with Neo4j and Cypher
 
Cypher Query Language
Cypher Query Language Cypher Query Language
Cypher Query Language
 
Intro to Cypher
Intro to CypherIntro to Cypher
Intro to Cypher
 
Introduction to Neo4j and .Net
Introduction to Neo4j and .NetIntroduction to Neo4j and .Net
Introduction to Neo4j and .Net
 
Neo4j -[:LOVES]-> Cypher
Neo4j -[:LOVES]-> CypherNeo4j -[:LOVES]-> Cypher
Neo4j -[:LOVES]-> Cypher
 

Similar to Introduction to graph databases, Neo4j and Spring Data - English 2015 Edition

Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklNeo4j
 
Graph Databases
Graph DatabasesGraph Databases
Graph Databasesthai
 
managing big data
managing big datamanaging big data
managing big dataSuveeksha
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataRoger Xia
 
New opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonNew opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonJAX London
 
Neo4j Training Introduction
Neo4j Training IntroductionNeo4j Training Introduction
Neo4j Training IntroductionMax De Marzi
 
Processing Large Graphs
Processing Large GraphsProcessing Large Graphs
Processing Large GraphsNishant Gandhi
 
Cypher and apache spark multiple graphs and more in open cypher
Cypher and apache spark  multiple graphs and more in  open cypherCypher and apache spark  multiple graphs and more in  open cypher
Cypher and apache spark multiple graphs and more in open cypherNeo4j
 
Intro to Graphs for Fedict
Intro to Graphs for FedictIntro to Graphs for Fedict
Intro to Graphs for FedictRik Van Bruggen
 
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedNeo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedsnehapandey01
 
ESWC SS 2012 - Tuesday Tutorial Dan Brickley and Denny Vrandecic: Linked Open...
ESWC SS 2012 - Tuesday Tutorial Dan Brickley and Denny Vrandecic: Linked Open...ESWC SS 2012 - Tuesday Tutorial Dan Brickley and Denny Vrandecic: Linked Open...
ESWC SS 2012 - Tuesday Tutorial Dan Brickley and Denny Vrandecic: Linked Open...eswcsummerschool
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph DatabasesMax De Marzi
 
Neo4j GraphTalk Helsinki - Introduction and Graph Use Cases
Neo4j GraphTalk Helsinki - Introduction and Graph Use CasesNeo4j GraphTalk Helsinki - Introduction and Graph Use Cases
Neo4j GraphTalk Helsinki - Introduction and Graph Use CasesNeo4j
 
Demo Neo4j - Big Data Paris
Demo Neo4j - Big Data ParisDemo Neo4j - Big Data Paris
Demo Neo4j - Big Data ParisNeo4j
 
Einführung in Neo4j
Einführung in Neo4jEinführung in Neo4j
Einführung in Neo4jNeo4j
 
Graph databases and the #panamapapers
Graph databases and the #panamapapersGraph databases and the #panamapapers
Graph databases and the #panamapapersdarthvader42
 
[Webinar] Introduction to Cypher
[Webinar] Introduction to Cypher[Webinar] Introduction to Cypher
[Webinar] Introduction to CypherNeo4j
 
Document Oriented Access to Graphs
Document Oriented Access to GraphsDocument Oriented Access to Graphs
Document Oriented Access to GraphsNeo4j
 

Similar to Introduction to graph databases, Neo4j and Spring Data - English 2015 Edition (20)

Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quickl
 
Graph Databases
Graph DatabasesGraph Databases
Graph Databases
 
managing big data
managing big datamanaging big data
managing big data
 
Neo4 jv2 english
Neo4 jv2 englishNeo4 jv2 english
Neo4 jv2 english
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_data
 
OWF12/Java Ian robinson
OWF12/Java Ian robinsonOWF12/Java Ian robinson
OWF12/Java Ian robinson
 
New opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian RobinsonNew opportunities for connected data - Ian Robinson
New opportunities for connected data - Ian Robinson
 
Neo4j Training Introduction
Neo4j Training IntroductionNeo4j Training Introduction
Neo4j Training Introduction
 
Processing Large Graphs
Processing Large GraphsProcessing Large Graphs
Processing Large Graphs
 
Cypher and apache spark multiple graphs and more in open cypher
Cypher and apache spark  multiple graphs and more in  open cypherCypher and apache spark  multiple graphs and more in  open cypher
Cypher and apache spark multiple graphs and more in open cypher
 
Intro to Graphs for Fedict
Intro to Graphs for FedictIntro to Graphs for Fedict
Intro to Graphs for Fedict
 
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedNeo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
 
ESWC SS 2012 - Tuesday Tutorial Dan Brickley and Denny Vrandecic: Linked Open...
ESWC SS 2012 - Tuesday Tutorial Dan Brickley and Denny Vrandecic: Linked Open...ESWC SS 2012 - Tuesday Tutorial Dan Brickley and Denny Vrandecic: Linked Open...
ESWC SS 2012 - Tuesday Tutorial Dan Brickley and Denny Vrandecic: Linked Open...
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
Neo4j GraphTalk Helsinki - Introduction and Graph Use Cases
Neo4j GraphTalk Helsinki - Introduction and Graph Use CasesNeo4j GraphTalk Helsinki - Introduction and Graph Use Cases
Neo4j GraphTalk Helsinki - Introduction and Graph Use Cases
 
Demo Neo4j - Big Data Paris
Demo Neo4j - Big Data ParisDemo Neo4j - Big Data Paris
Demo Neo4j - Big Data Paris
 
Einführung in Neo4j
Einführung in Neo4jEinführung in Neo4j
Einführung in Neo4j
 
Graph databases and the #panamapapers
Graph databases and the #panamapapersGraph databases and the #panamapapers
Graph databases and the #panamapapers
 
[Webinar] Introduction to Cypher
[Webinar] Introduction to Cypher[Webinar] Introduction to Cypher
[Webinar] Introduction to Cypher
 
Document Oriented Access to Graphs
Document Oriented Access to GraphsDocument Oriented Access to Graphs
Document Oriented Access to Graphs
 

Recently uploaded

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

Introduction to graph databases, Neo4j and Spring Data - English 2015 Edition

  • 1. Introduc)on  to  graph  databases,  Neo4j   and  Spring  Data     Aleksander  M.  Stensby   Monokkel  A/S  
  • 2. •  Aleksander  M.  Stensby   •  CEO  in  Monokkel  AS   •  Previously  COO  in  Integrasco  AS   •  Working  with  search  and  data  analysis  since  2004   www.monokkel.io  
  • 3. •  Daglig  leder  i  Monokkel  AS   •  Tidligere  COO  i  Integrasco  AS   •  Persistering,  Prosessering  og  Presentasjon  av  data   Persistence  –  Processing  –  PresentaHon  
  • 4. Agenda   •  Intro  to  graph  databases  and  modelling     •  Neo4j  and  Cypher     •  SpringData  Neo4j  
  • 6. …when  it  comes  to  relaHons  
  • 7. RelaHonal  databases  are  awesome   when  it  comes  to  aggregaHon  of  data,   schema  mapping  and  tabular  data!  
  • 9. We  have  a  tendency  to  force     _all_     our  problems  into  our  relaHonal   databases!  
  • 14. NoSQL   •  Key-­‐value  stores   – Amazon  Dynamo   – Ex:  Voldemort,...   •  BigTable  clones   – Google’s  BigTable   – Ex:  Hbase,  ...   •  Document  databases   – Lotus  Notes   – Ex:  MongoDB,  CouchDB  
  • 15. NoSQL   •  Graph  databases   – Euler  and  graph  theory   – Ex:  Neo4j,  VertexDB,  AllegroGraph,   Giraphe,  OrientDB,  etc...  
  • 16. NoSQL  Size   Complexity   Graphs   Document   BigTable   KV  
  • 17. NoSQL  Size   Complexity   Graphs   Document   BigTable   KV   90%   Billions  of  nodes  and  rela)onships  
  • 20. Person   ID   Name   Friends   PersonID   FriendID  
  • 21. Person   ID   Name   Friends   PersonID   FriendID   «Aleks»’s  friends   SELECT  p1.Person   FROM  Person  p1  JOIN  Friends    ON  Friends.FriendID  =  p1.ID   JOIN  Person  p2    ON  Friends.PersonID  =  p2.ID   WHERE  p2.Name=  'Aleks'  
  • 22. Person   ID   Name   Friends   PersonID   FriendID   Friends  with  «Aleks»   SELECT  p1.Person   FROM  Person  p1  JOIN  Friends    ON  Friends.PersonID  =  p1.ID   JOIN  Person  p2    ON  Friends.FriendID  =  p2.ID   WHERE  p2.Name  =  'Aleks'  
  • 23. Person   ID   Name   Friends   PersonID   FriendID   «Aleks»’s  friends’  friends?   SELECT  p1.Person  AS  PERSON,  p2.Person  AS  FRIEND_OF_FRIEND   FROM  Friends  v1  JOIN  Person  p1    ON  v1.PersonID  =  p1.ID   JOIN  Friends  v2    ON  v2.FriendID  =  v1.FriendID   JOIN  Person  p2    ON  v2.FriendID  =  p2.  ID   WHERE  p1.Name  =  'Aleks‘  AND  v2.FriendID  <>  p1.ID  
  • 24. Source:  Neo4j  in  AcHon 1,000,000  persons   Depth   RDBMS   Neo4j   Records   2   0.016   0.01   ~  2500   3   30.267   0.168   ~  110,000   4   1543.505   1.359   ~  600,000   5   DNF   2.132   ~  800,000  
  • 25.
  • 26. A  graph  database...   •  uses  graph  structures  with   – Nodes   – RelaHonships   – Apributes     •  to  store  informaHon!   •  Exellent  for  relaHonships  –  but  not  necessarily   best  at  aggregaHng  data  
  • 27. Graph  databases  and  neo4j   •  Visual  –  Schema  less!     •  Doubly-­‐linked-­‐lists   – each  node  has  a  list  of  incoming  and  outgoing   relaWonships     •  Direct  lookup  =  O(1)  
  • 28. A  graph  stores  data  in  nodes   ALEKS   TARJEI  
  • 29. Nodes  are  connected  by  relaWonships   FRIENDS_WITH   ALEKS   TARJEI  
  • 30. Nodes  have  aributes   ALEKS   TARJEI   Age:  29   First  Name:  Aleksander   Last  Name:  Stensby     Age:  30   First  Name:  Tarjei   Last  Name:  Romtveit     FRIENDS_WITH  
  • 31. RelaWonships  can  also  have  aributes   ALEKS   TARJEI   Age:  29   First  Name:  Aleksander   Last  Name:  Stensby     Age:  30   First  Name:  Tarjei   Last  Name:  Romtveit     FRIENDS_WITH   Since:  01.01.2004  
  • 32. RelaWonships  can  be  bi-­‐direcHonal   ALEKS   TARJEI   Age:  29   First  Name:  Aleksander   Last  Name:  Stensby     Age:  30   First  Name:  Tarjei   Last  Name:  Romtveit     FRIENDS_WITH   Since:  01.01.2004   FRIENDS_WITH   Since:  01.01.2004  
  • 33. ALEKS   TARJEI   Age:  29   First  Name:  Aleksander   Last  Name:  Stensby     Age:  30   First  Name:  Tarjei   Last  Name:  Romtveit     FRIENDS_WITH   Since:  01.01.2004  
  • 34. ALEKS   TARJEI   Age:  29   First  Name:  Aleksander   Last  Name:  Stensby   Type:  Person     Age:  30   First  Name:  Tarjei   Last  Name:  Romtveit   Type:  Person     FRIENDS_WITH   Since:  01.01.2004   different  types  of  nodes  
  • 35. Person   Person   Sport   Programming  language   Drink   Person  
  • 36. Some  use  cases   •  Social  Media   •  RecommendaHons   •  Geo  rouHng  and  logisHcs   •  Access  management   •  Network  management   •  Finance  /  Fraud  
  • 37. Neo4j  –  [IS_A]  -­‐>  Property  Graph  
  • 38. Neo4j  2.2.x   •  Currently  early  access  milestone  4   •  New  page  cache  -­‐>  high  concurrency     •  TransacHonal  and  batch  write  performance   •  Cost-­‐Based  OpHmizer  for  Cypher  
  • 39.
  • 40. (node)  –  [relaHonship]  -­‐>  (node)  
  • 41. (Aleks)  –  [FRIENDS_WITH]  -­‐>  (Tarjei)  
  • 42. Cypher   "Make  the  simple  things  simple,  and  the  complex  things  possible"  
  • 43. Intro  to  Cypher   •  START   •  MATCH   •  WHERE   •  RETURN   •  CREATE   •  DELETE   •  SET   •  FOREACH   •  WITH  
  • 44. MATCH  <papern>     WHERE   RETURN    
  • 45. Describe  what  you  want  to  retrieve   with  PATTERNS   (a)-­‐[r]-­‐>(b)  
  • 46. (Aleks)  –  [FRIENDS_WITH]  -­‐>  (Tarjei)  
  • 48. START   START  n=node(1)   RETURN  n  
  • 49. MATCH   MATCH  (movie:Movie)   RETURN  movie  
  • 50. WHERE   MATCH  movie   WHERE  move.Htle  =  ‘Blade  Runner'   RETURN  movie  
  • 51. START  a=node(*)   MATCH  (a:Person)   WHERE  a.name='Danny  DeVito'   RETURN  a  
  • 52. START  a=node(*)   MATCH  (a:Person)   WHERE  a.name='Danny  DeVito'   RETURN  a  
  • 53. START  a=node(*)   MATCH  (a:Person  {name:  'Danny  DeVito'}  )   WHERE  a.name='Danny  DeVito'   RETURN  a   Neo4j  2.0.1  
  • 54. Friend  of  friend...   MATCH  (aleks)-­‐[r:KNOWS]-­‐()-­‐[r2:KNOWS]  -­‐>(friend_of_friend)   WHERE  aleks.firstName=  'Aleks'   RETURN  friend_of_friend.firstName  
  • 55. Friend  of  friend...   MATCH  (aleks)-­‐[:KNOWS*2..2]-­‐>(friend_of_friend)   WHERE  aleks.firstName=  'Aleks'   AND  NOT  (aleks)-­‐[:KNOWS]-­‐>(friend_of_friend)   RETURN  friend_of_friend.firstName  
  • 57.           DEMO    
  • 58. And  a  whole  lot  more…   •  Traversals  to  navigate  the  graph   •  Traversals  idenHfy  paths   •  Paths  order  nodes   •  Cypher  parameters   •  Indexes   •  Neo4j  embedded,  Neo4j  REST   •  Neo4j  2.x  –  Labels  and  automaWc  indexes   •  Gremlin  (procedural)  –  Cypher  (declaraHve)   •  Enterprise  (mulH-­‐instance  cluster,  online  backup)   •  Neo4j  SpaWal  
  • 61.
  • 62. Intro  to  SpringData  Neo4j   •  SpringData   •  Repositories   •  Quick  example   <dependencies>          <dependency>                  <groupId>org.springframework.data</groupId>                  <arHfactId>spring-­‐data-­‐neo4j</arHfactId>                  <version>3.2.2.RELEASE</version>          </dependency>   </dependencies>   neo4j      2.1.7   spring-­‐data-­‐neo4j    3.2.2   spring      4.1.4  
  • 63. SpringData  Neo4j  Config   @Configuration   @EnableNeo4jRepositories("no.stensby.javabin.neo.repositories")   public  class  Config  extends  Neo4jConfiguration  {   }   @Autowired   protected  Neo4jTemplate  template;  
  • 64. SpringData  Neo4j  Config   @Configuration   @EnableNeo4jRepositories("no.stensby.javabin.neo.repositories")   public  class  Config  extends  Neo4jConfiguration  {      public  Config  (){                  setBasePackage("no.stensby.javabin.neo.domain");          }     }   @Autowired   protected  Neo4jTemplate  template;  
  • 65. SpringData  Neo4j  Config   @Bean   GraphDatabaseService  graphDatabaseService()  {   return  new  GraphDatabaseFactory().newEmbeddedDatabase("tmp/neo4j");   }   Embedded:   REST:     @Bean   GraphDatabaseService  graphDatabaseService()  {   return  new  SpringRestGraphDatabase("http://localhost:7474/db/data");   }   @Bean(destroyMethod  =  "shutdown")   @Scope(SCOPE_PROTOTYPE)   public  GraphDatabaseService  graphDatabaseService()  {   return  new  TestGraphDatabaseFactory().newImpermanentDatabase();   }   TEST:    
  • 66. SpringData  Neo4j  -­‐  Domain   @NodeEntity   public  class  Person  {   @GraphId   public  Long  nodeId;     @Indexed(unique  =  true)   public  int  id;     public  String  firstName;   public  String  lastName;   }  
  • 67. 1-­‐1  relaHonships   @NodeEntity   public  class  Address  {     private  Country  country;     ...   }  
  • 68. 1-­‐1  relaHonships   @NodeEntity   public  class  Address  {     @Fetch   private  Country  country;     ...   }  
  • 69. 1-­‐m  relaHonships  -­‐  @RelatedTo   @RelatedTo(type  =  "ADDRESS")   private  Set<Address>  addresses  =  new  HashSet<Address>();   @RelatedTo   private  Set<Person>  venner  =  new  HashSet<Person>  ();  
  • 70. m-­‐m  relaHonships  -­‐  @RelatedToVia   @Fetch   @RelatedToVia  (type  =  "ACTS_IN")   Set<Role>  roles  =  new   HashSet<Role>();   @Fetch   @RelatedToVia(type  =  "ACTS_IN",  direction  =  Direction.INCOMING)     Set<Role>  cast  =  new  HashSet<Role>();   Actor  Movie   @RelationshipEntity(type  =  "ACTS_IN")   public  class  Role  {   @GraphId   Long  nodeId;   @StartNode   Actor  actor;   @EndNode   Movie  movie;   Role  
  • 71. SpringData  Neo4j  -­‐  Repositories   GraphRepository<Person>  personRepository  =  template.repositoryFor(Person.class);   @Autowired   Neo4jTemplate  template;  
  • 72. SpringData  Neo4j  -­‐  Repositories   public  interface  PersonRepository  extends  GraphRepository<Person>{}   @Autowired   PersonRepository  repository;  
  • 73. SpringData  Neo4j  -­‐  Repositories   public  interface  PersonRepository  extends  GraphRepository<Person>{       List<Person>  findByFirstName(String  firstName);     }  
  • 74. SpringData  Neo4j  -­‐  Repositories   public  interface  PersonRepository  extends  GraphRepository<Person>{       List<Person>  findByFirstName(String  firstName);     @Query("MATCH  (p:Person{firstName:{0}})  RETURN  p")     List<Person>  getPersonWithFirstName  (String  firstName);     }  
  • 75. SpringData  Neo4j  -­‐  Repositories   public  interface  PersonRepository  extends  GraphRepository<Person>{       List<Person>  findByFirstName(String  firstName);     @Query("MATCH  (p:Person{firstName:{0}})  RETURN  p")     List<Person>  getPersonWithFirstName  (String  firstName);       @Query(  "MATCH  (p:Person{firstName:{0}})-­‐[:knows]-­‐>friends  "  +    "  RETURN  friends")     Iterable<Person>  findFriendsOfPerson(String  firstName);       }  
  • 76. Lessons  Learned   •  Be  careful  with  versions  and  upgrading  …   –  Neo  1.9.x  -­‐>  Neo  2.x  =  lots  of  problems…   –  Lots  of  breaking  changes…   –  Spring  Data  Neo4j  !=  Neo4j     •  Nodes  are  “first-­‐class”  ciHzens  in  the  graph   –  Hyperedges  are  not  supported  -­‐>  use  “event  nodes”     •  AggregaHons  are  expensive  –  caching  stats  on  nodes!   •  Unique  and  expressive  relaHonship  types  
  • 77. Pi•alls   •  Don’t  use  the  graphid  as  your  ID   •  IniHalize  Set   •  Use  @Fetch  with  care   •  Use  standard  gepers/sepers   •  Be  careful  with  String  escaping  
  • 78. InspiraHon   •  Single  Malt  Scotch  Whisky   hpp://gist.neo4j.org/?8139605     •  Chess  Games  and  PosiWons   hpp://gist.neo4j.org/?6506717     •  Movie  RecommendaWons   hpp://gist.neo4j.org/?8173017   •  Food  Recipes  RecommendaWon   hpp://gist.neo4j.org/?8731452