SlideShare uma empresa Scribd logo
1 de 21
evandro.venancio@gmail.com

@evenancio

evenancio.wordpress.com

linkedin.com/in/evandrovenancio
O que é um Grafo ???
Vértice = Nó
Arco = Relacionamento
arco
Vértice A

Vértice B
Santos

Rodovia dos
Imigrantes

São Bernardo do Campo

São Paulo

Rodovia dos
Imigrantes
[:imigrantes]

São
Bernardo do
Campo

Santos

São Paulo
1736
Leonhard Euler

As pontes de Königsberg
SOME FEATURES

#Big Data tools
#Data Center and
Cloud Software
#Technology of
the Year

•
•
•
•
•
•
•
•
•

Totalmente Transacional (ACID)
Tem controle de concorrência
Armazenamento próprio baseado em discos
Escalável para múltiplas máquinas
Possui uma linguagem intuitiva (Cypher)
Possui interface RESTFul
Possui API nativa em Java
Pode ser distribuído como um servidor Standalone
Pode ser embutido na aplicação
Let’s to play ???
#The Smith Family lab#
Dad

Mom

John Smith
our hero
bastard
bro

sister
beautiful
wife

my cousin

my children
CYPHER – Creating the Smith family -> 11 nodes
CREATE
CREATE
CREATE
CREATE
CREATE
CREATE
CREATE
CREATE
CREATE
CREATE
CREATE

(dad:People {name:"Joseph Smith", datebirth: 1961 })
(mom:People {name:"Joan Smith", datebirth: 1963 })
(me:People {name:"John Smith", datebirth: 1982 })
(sister:People {name:"Josephine Smith", datebirth: 1986 })
(bro:People {name:"Jonathan Smith", datebirth: 1994 })
(wife:People {name:"Jennifer K. L. Smith", datebirth: 1984 })
(children1:People {name:"Jen-El Smith", datebirth: 2005 })
(children2:People {name:"Jil-El Smith", datebirth: 2007 })
(children3:People {name:"Juju-El Smith", datebirth: 2011 })
(children4:People {name:"Jor-El Smith", datebirth: 2013 })
(cousin:People {name:"Cousine Smith Oliver", datebirth: 2013 })
CYPHER – Creating the basic relationship between the
Smiths 1/2
MATCH (dad:People {name:"Joseph Smith" })
MATCH (mom:People {name:"Joan Smith" })
MATCH (me:People {name:"John Smith" })
MATCH (sister:People {name:"Josephine Smith" })
MATCH (bro:People {name:"Jonathan Smith" })
CREATE (me)-[:IS_SON_OF]->(dad)
CREATE (me)-[:IS_SON_OF]->(mom)
CREATE (sister)-[:IS_SON_OF]->(dad)
CREATE (sister)-[:IS_SON_OF]->(mom)
CREATE (bro)-[:IS_SON_OF]->(dad)
CYPHER – Creating the basic relationship between the
Smiths 2/2
MATCH (sister:People {name:"Josephine Smith" })
MATCH (cousin:People {name:"Cousine Smith Oliver" })
MATCH (me:People {name:"John Smith" })
MATCH (wife:People {name:"Jennifer K. L. Smith" })
MATCH (children1:People {name:"Jen-El Smith" })
MATCH (children2:People {name:"Jil-El Smith" })
MATCH (children3:People {name:"Juju-El Smith" })
MATCH (children4:People {name:"Jor-El Smith" })
CREATE (cousin)-[:IS_SON_OF]->(sister)
CREATE (me)-[:IS_MARRIED_WITH]->(wife)
CREATE (children1)-[:IS_SON_OF]->(me)
CREATE (children2)-[:IS_SON_OF]->(me)
CREATE (children2)-[:IS_SON_OF]->(wife)
CREATE (children3)-[:IS_SON_OF]->(me)
CREATE (children3)-[:IS_SON_OF]->(wife)
CREATE (children4)-[:IS_SON_OF]->(me)
CREATE (children4)-[:IS_SON_OF]->(wife)
SOME QUESTIONS!!!
1) Quem são os pais de John Smith?
MATCH (me:People {name:"John Smith" })
MATCH (me)-[:IS_SON_OF]->(parents)
RETURN parents.name

2) Quem são os filhos de John Smith?
MATCH (me:People {name:"John Smith" })
MATCH (me)<-[:IS_SON_OF]-(children)
RETURN children.name

3) Quem são os irmãos de John Smith?
MATCH (me:People {name:"John Smith" })
MATCH (me)-[:IS_SON_OF]->(parents)<-[:IS_SON_OF]-(brothers)
RETURN DISTINCT brothers.name

4) Quem são os irmãos de John Smith do mesmo pai e da mesma mãe?
MATCH (me:People {name:"John Smith" })
MATCH (me)-[:IS_SON_OF]->(parents)<-[:IS_SON_OF]-(brothers)
WITH me, brothers, count(parents) as parents_count
WHERE parents_count = length(me-[:IS_SON_OF]->())
RETURN brothers.name
5) Quem são os primos de Cousine?
MATCH (cousin:People {name:"Cousine Smith Oliver" })
MATCH (cousin)-[:IS_SON_OF]->(mysister)
MATCH (mysister)-[:IS_SON_OF]->(ourparents)<-[:IS_SON_OF]-(brothers_of_my_sister)
MATCH (brothers_of_my_sister)<-[:IS_SON_OF]-(sons_of_brothers_of_my_sister)
RETURN DISTINCT sons_of_brothers_of_my_sister.name

Para finalizar, vamos deixar um pouco mais
complexo!
6) Quem são os primos de Cousine que torcem para o Chelsea?
6.1 – Creating Nodes
MATCH (children1:People {name:"Jen-El Smith" })
MATCH (children4:People {name:"Jor-El Smith” })
CREATE (chelsea:SoccerTeam { name: “Chelsea”})
CREATE (children1)-[:IS_FAN_OF]->(chelsea)
CREATE (children4)-[:IS_FAN_OF]->(chelsea)

6.2 MATCH
MATCH
MATCH
MATCH
MATCH
WHERE

Query

(cousin:People {name:"Cousine Smith Oliver" })
(cousin)-[:IS_SON_OF]->(mysister)
(mysister)-[:IS_SON_OF]->(ourparents)<-[:IS_SON_OF]-(brothers_of_my_sister)
(brothers_of_my_sister)<-[:IS_SON_OF]-(sons_of_brothers_of_my_sister)
(sons_of_brothers_of_my_sister)-[:IS_FAN_OF]->(soccer_team)
soccer_team.name = "Chelsea"
evandro.venancio@gmail.com

@evenancio

evenancio.wordpress.com

linkedin.com/in/evandrovenancio

Mais conteúdo relacionado

Destaque

Persistent graphs in Python with Neo4j
Persistent graphs in Python with Neo4jPersistent graphs in Python with Neo4j
Persistent graphs in Python with Neo4jTobias Lindaaker
 
Web Semântica e bancos de dados NoSQL
Web Semântica e bancos de dados NoSQLWeb Semântica e bancos de dados NoSQL
Web Semântica e bancos de dados NoSQLOtávio Calaça Xavier
 
Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Peter Neubauer
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph DatabasesMax De Marzi
 
Webinar: Stop Complex Fraud in its Tracks with Neo4j
Webinar: Stop Complex Fraud in its Tracks with Neo4jWebinar: Stop Complex Fraud in its Tracks with Neo4j
Webinar: Stop Complex Fraud in its Tracks with Neo4jNeo4j
 
Introducao aos Bancos de Dados Não-relacionais
Introducao aos Bancos de Dados Não-relacionaisIntroducao aos Bancos de Dados Não-relacionais
Introducao aos Bancos de Dados Não-relacionaisMauricio De Diana
 
Neo4j Partner Tag Berlin - Investigating the Panama Papers connections with n...
Neo4j Partner Tag Berlin - Investigating the Panama Papers connections with n...Neo4j Partner Tag Berlin - Investigating the Panama Papers connections with n...
Neo4j Partner Tag Berlin - Investigating the Panama Papers connections with n...Neo4j
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenLorenzo Alberton
 
OrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityOrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityCurtis Mosters
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4jNeo4j
 

Destaque (12)

No sql std
No sql stdNo sql std
No sql std
 
Persistent graphs in Python with Neo4j
Persistent graphs in Python with Neo4jPersistent graphs in Python with Neo4j
Persistent graphs in Python with Neo4j
 
Introdução ao neo4j
Introdução ao neo4jIntrodução ao neo4j
Introdução ao neo4j
 
Web Semântica e bancos de dados NoSQL
Web Semântica e bancos de dados NoSQLWeb Semântica e bancos de dados NoSQL
Web Semântica e bancos de dados NoSQL
 
Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.Neo4j Spatial - GIS for the rest of us.
Neo4j Spatial - GIS for the rest of us.
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
Webinar: Stop Complex Fraud in its Tracks with Neo4j
Webinar: Stop Complex Fraud in its Tracks with Neo4jWebinar: Stop Complex Fraud in its Tracks with Neo4j
Webinar: Stop Complex Fraud in its Tracks with Neo4j
 
Introducao aos Bancos de Dados Não-relacionais
Introducao aos Bancos de Dados Não-relacionaisIntroducao aos Bancos de Dados Não-relacionais
Introducao aos Bancos de Dados Não-relacionais
 
Neo4j Partner Tag Berlin - Investigating the Panama Papers connections with n...
Neo4j Partner Tag Berlin - Investigating the Panama Papers connections with n...Neo4j Partner Tag Berlin - Investigating the Panama Papers connections with n...
Neo4j Partner Tag Berlin - Investigating the Panama Papers connections with n...
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and when
 
OrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityOrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionality
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
 

Último

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Último (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Neo4j - Rede de relacionamentos baseada em grafos

  • 2. O que é um Grafo ??? Vértice = Nó Arco = Relacionamento arco Vértice A Vértice B
  • 3. Santos Rodovia dos Imigrantes São Bernardo do Campo São Paulo Rodovia dos Imigrantes
  • 6. SOME FEATURES #Big Data tools #Data Center and Cloud Software #Technology of the Year • • • • • • • • • Totalmente Transacional (ACID) Tem controle de concorrência Armazenamento próprio baseado em discos Escalável para múltiplas máquinas Possui uma linguagem intuitiva (Cypher) Possui interface RESTFul Possui API nativa em Java Pode ser distribuído como um servidor Standalone Pode ser embutido na aplicação
  • 7.
  • 8.
  • 9. Let’s to play ??? #The Smith Family lab#
  • 11. CYPHER – Creating the Smith family -> 11 nodes CREATE CREATE CREATE CREATE CREATE CREATE CREATE CREATE CREATE CREATE CREATE (dad:People {name:"Joseph Smith", datebirth: 1961 }) (mom:People {name:"Joan Smith", datebirth: 1963 }) (me:People {name:"John Smith", datebirth: 1982 }) (sister:People {name:"Josephine Smith", datebirth: 1986 }) (bro:People {name:"Jonathan Smith", datebirth: 1994 }) (wife:People {name:"Jennifer K. L. Smith", datebirth: 1984 }) (children1:People {name:"Jen-El Smith", datebirth: 2005 }) (children2:People {name:"Jil-El Smith", datebirth: 2007 }) (children3:People {name:"Juju-El Smith", datebirth: 2011 }) (children4:People {name:"Jor-El Smith", datebirth: 2013 }) (cousin:People {name:"Cousine Smith Oliver", datebirth: 2013 })
  • 12.
  • 13. CYPHER – Creating the basic relationship between the Smiths 1/2 MATCH (dad:People {name:"Joseph Smith" }) MATCH (mom:People {name:"Joan Smith" }) MATCH (me:People {name:"John Smith" }) MATCH (sister:People {name:"Josephine Smith" }) MATCH (bro:People {name:"Jonathan Smith" }) CREATE (me)-[:IS_SON_OF]->(dad) CREATE (me)-[:IS_SON_OF]->(mom) CREATE (sister)-[:IS_SON_OF]->(dad) CREATE (sister)-[:IS_SON_OF]->(mom) CREATE (bro)-[:IS_SON_OF]->(dad)
  • 14.
  • 15. CYPHER – Creating the basic relationship between the Smiths 2/2 MATCH (sister:People {name:"Josephine Smith" }) MATCH (cousin:People {name:"Cousine Smith Oliver" }) MATCH (me:People {name:"John Smith" }) MATCH (wife:People {name:"Jennifer K. L. Smith" }) MATCH (children1:People {name:"Jen-El Smith" }) MATCH (children2:People {name:"Jil-El Smith" }) MATCH (children3:People {name:"Juju-El Smith" }) MATCH (children4:People {name:"Jor-El Smith" }) CREATE (cousin)-[:IS_SON_OF]->(sister) CREATE (me)-[:IS_MARRIED_WITH]->(wife) CREATE (children1)-[:IS_SON_OF]->(me) CREATE (children2)-[:IS_SON_OF]->(me) CREATE (children2)-[:IS_SON_OF]->(wife) CREATE (children3)-[:IS_SON_OF]->(me) CREATE (children3)-[:IS_SON_OF]->(wife) CREATE (children4)-[:IS_SON_OF]->(me) CREATE (children4)-[:IS_SON_OF]->(wife)
  • 16.
  • 17. SOME QUESTIONS!!! 1) Quem são os pais de John Smith? MATCH (me:People {name:"John Smith" }) MATCH (me)-[:IS_SON_OF]->(parents) RETURN parents.name 2) Quem são os filhos de John Smith? MATCH (me:People {name:"John Smith" }) MATCH (me)<-[:IS_SON_OF]-(children) RETURN children.name 3) Quem são os irmãos de John Smith? MATCH (me:People {name:"John Smith" }) MATCH (me)-[:IS_SON_OF]->(parents)<-[:IS_SON_OF]-(brothers) RETURN DISTINCT brothers.name 4) Quem são os irmãos de John Smith do mesmo pai e da mesma mãe? MATCH (me:People {name:"John Smith" }) MATCH (me)-[:IS_SON_OF]->(parents)<-[:IS_SON_OF]-(brothers) WITH me, brothers, count(parents) as parents_count WHERE parents_count = length(me-[:IS_SON_OF]->()) RETURN brothers.name
  • 18. 5) Quem são os primos de Cousine? MATCH (cousin:People {name:"Cousine Smith Oliver" }) MATCH (cousin)-[:IS_SON_OF]->(mysister) MATCH (mysister)-[:IS_SON_OF]->(ourparents)<-[:IS_SON_OF]-(brothers_of_my_sister) MATCH (brothers_of_my_sister)<-[:IS_SON_OF]-(sons_of_brothers_of_my_sister) RETURN DISTINCT sons_of_brothers_of_my_sister.name Para finalizar, vamos deixar um pouco mais complexo!
  • 19. 6) Quem são os primos de Cousine que torcem para o Chelsea? 6.1 – Creating Nodes MATCH (children1:People {name:"Jen-El Smith" }) MATCH (children4:People {name:"Jor-El Smith” }) CREATE (chelsea:SoccerTeam { name: “Chelsea”}) CREATE (children1)-[:IS_FAN_OF]->(chelsea) CREATE (children4)-[:IS_FAN_OF]->(chelsea) 6.2 MATCH MATCH MATCH MATCH MATCH WHERE Query (cousin:People {name:"Cousine Smith Oliver" }) (cousin)-[:IS_SON_OF]->(mysister) (mysister)-[:IS_SON_OF]->(ourparents)<-[:IS_SON_OF]-(brothers_of_my_sister) (brothers_of_my_sister)<-[:IS_SON_OF]-(sons_of_brothers_of_my_sister) (sons_of_brothers_of_my_sister)-[:IS_FAN_OF]->(soccer_team) soccer_team.name = "Chelsea"
  • 20.