SlideShare a Scribd company logo
CS331 - Database Management Systems


Dr. Lilia Sfaxi


17 novembre 2019


Neo4J


1. Graph-based Databases : Neo4J


1.1. Graphs


Formally, a graph is a collection of nodes and arcs that connect them. The
graphs represent the entities in the form of nodes, and the ways in which these
entities are connected in the form of arcs. This structure inspired the graph-
oriented databases, because they make it possible to model all types of scenarios.


For example, the relationships between Twitter users can be represented in a
simpli
fi
ed way by the following graph:


A graph can represent any type of data.


- A node is the equivalent of a record


- A relation makes it possible to connect nodes, and can be typed


- Nodes and relationships can have properties, representing named
attributes


- A label is a name allowing to organize the nodes in groups


NEO4J DR. LILIA SFAXI 1
MedTech
The database we will use in this lab is Neo4j . This database uses the Cypher
1
language to represent queries.


1.2.Example


The example we will show in this manuscript is taken from the tutorial provided
by Neo4j in their site on this link: http://neo4j.com/graphacademy/online-
course/


The data we process represents:


- Movies with a label : Movie and the properties title, released and tagline


- People with a label : Person and the properties name and born


- An ACTED_IN relation from an actor to a movie, with a roles property
containing the list of character names


- A DIRECTED relationship from a director to a
fi
lm.


Activity 1


Launch Neo4J on your browser. The default login/password is neo4j/neo4j (they will
ask you to change after
fi
rst authentication).


Create the Movies database given as an example by the tool by following these steps:


- Once authenticated and the default password replaced, choose: "Jump Into Code" to
start developing.


- Click on "Create a Graph" in the "Movie Graph" section as follows:


Neo4J: http://neo4j.com/
1
NEO4J DR. LILIA SFAXI 2
- In the window that appears, click on the graph creation code to load it into the
editor. Then run it.


1.3.The Cipher Language


Nodes
(a) Actors
(m) Films
( ) Anonymous Node
Relations
-[r]-> A relation called r
(a) –[r]-> (m) Actors having a relation r with movies
-[:ACTED_IN]-> The relation is of type ACTED_IN
(a)-[:ACTED_IN]->(m) Actors who play in a movie
(d)-[:DIRECTED]->(m) The directors of a
fi
lm
Properties of Nodes
(m {title : "The Matrix"}) Movie with a property title
(a {name: "Keanu Reeves", born : 1964}) Actor with properties name and born
NEO4J DR. LILIA SFAXI 3
Properties of Relations
(a)-[ :ACTED_IN {roles :[« Neo »]}]->(m) Relation ACTED_IN with the
propperty roles, which is an array of
names
Labels
Allow to recognize different types of nodes.
(a:Person)-[:ACTED_IN]->(m:Movie) A person who has played in a movie
1.4. Cipher queries


1.4.1. Simple read requests


Here are some examples of Cipher queries:


The
fi
rst statement returns the value of the property property for all nodes.
The second one, returns the values of propertyA and propertyB of each pair
of nodes node2 and node1 which are connected by a relation (whatever its
nature).


To return only nodes connected by a relation of type REL_TYPE:


NEO4J DR. LILIA SFAXI 4
If the relation in question contains properties that one wishes to read, give
it a name (here rel):


To indicate a particular type of nodes, use the labels:


It is possible to assign an identi
fi
er to a relation, then return the type of the
relation, or its properties:


To support by an example, consider the following graph:


The query to
fi
nd all the characters in The Matrix movie is:


NEO4J DR. LILIA SFAXI 5
Another way is also possible to
fi
lter the data (instead of the traditional
WHERE), by replacing the previous query by:


Activity 2. Run the following queries in your editor:


- Give all movies where Tom Hanks played


- Give the list of all Matrix characters


- Give each
fi
lm its release date


1.4.2.	Paths


A path is a set of connected nodes and relationships, which can be a
pattern. For example :


(a) -> (b) -> (c)


(a) -> (b) <- (c)


Example: To show all actors and directors of all movies:


It is also possible to divide the query into several paths, as follows:


Or:


NEO4J DR. LILIA SFAXI 6
The results of previous queries are tables.


It is possible to return the entire path, with all the properties of all nodes
and relationships involved:


If this is too much information, you can just select the nodes of the path:


... or only relationships:


Activity 3. Execute the following queries in your editor:


- Which directors have played in their own movies?


- Give the movies where Keanu Reeves played the role of Neo.


- Which actors have already played in the same movie with Tom Hanks,
and in which
fi
lm?


- Which actors played in the same movie with Tom Hanks, and with
Keanu Reeves?


- Who are the characters in the movie "The Matrix"?


1.4.3. Edit a graph with Cipher


To add a node to the graph:


To add (or modify) properties to an existing node:


NEO4J DR. LILIA SFAXI 7
To add a relationship between two existing nodes:


Activity 4. Run the following queries in your editor:


- Create a movie called Mystic River


- Add Kevin Bacon as an actor in the movie "Mystic River" with the role
"Sean"


- Change the role to become "Sean Devine"
NEO4J DR. LILIA SFAXI 8

More Related Content

What's hot

TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-Correction
Lilia Sfaxi
 
Systèmes d'Exploitation - chp1-introduction
Systèmes d'Exploitation - chp1-introductionSystèmes d'Exploitation - chp1-introduction
Systèmes d'Exploitation - chp1-introduction
Lilia Sfaxi
 
Tp3 - Application SOA avec BPEL
Tp3 - Application SOA avec BPELTp3 - Application SOA avec BPEL
Tp3 - Application SOA avec BPEL
Lilia Sfaxi
 
Architectures 3-tiers (Web)
Architectures 3-tiers (Web)Architectures 3-tiers (Web)
Architectures 3-tiers (Web)
Heithem Abbes
 
PFE : ITIL - Gestion de parc informatique
PFE : ITIL - Gestion de parc informatiquePFE : ITIL - Gestion de parc informatique
PFE : ITIL - Gestion de parc informatique
chammem
 
exercices business intelligence
exercices business intelligence exercices business intelligence
exercices business intelligence
Yassine Badri
 
Chp2 - Diagramme des Cas d'Utilisation
Chp2 - Diagramme des Cas d'UtilisationChp2 - Diagramme des Cas d'Utilisation
Chp2 - Diagramme des Cas d'Utilisation
Lilia Sfaxi
 
diagramme de séquence UML
diagramme de séquence UMLdiagramme de séquence UML
diagramme de séquence UML
Amir Souissi
 
Support de cours Spring M.youssfi
Support de cours Spring  M.youssfiSupport de cours Spring  M.youssfi
Support de cours Spring M.youssfi
ENSET, Université Hassan II Casablanca
 
BigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-ReduceBigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-Reduce
Lilia Sfaxi
 
Formation JAVA/J2EE
Formation JAVA/J2EEFormation JAVA/J2EE
Formation JAVA/J2EE
Ines Ouaz
 
Chp3 - Modélisation Multidimensionnelle
Chp3 - Modélisation MultidimensionnelleChp3 - Modélisation Multidimensionnelle
Chp3 - Modélisation Multidimensionnelle
Lilia Sfaxi
 
Introduction aux systèmes répartis
Introduction aux systèmes répartisIntroduction aux systèmes répartis
Introduction aux systèmes répartis
Heithem Abbes
 
Chp1 - Introduction aux méthodologies de Conception
Chp1 - Introduction aux méthodologies de ConceptionChp1 - Introduction aux méthodologies de Conception
Chp1 - Introduction aux méthodologies de Conception
Lilia Sfaxi
 
Modélisation de données pour MongoDB
Modélisation de données pour MongoDBModélisation de données pour MongoDB
Modélisation de données pour MongoDB
MongoDB
 
Cours Big Data Chap5
Cours Big Data Chap5Cours Big Data Chap5
Cours Big Data Chap5
Amal Abid
 
eServices-Tp1: Web Services
eServices-Tp1: Web ServiceseServices-Tp1: Web Services
eServices-Tp1: Web Services
Lilia Sfaxi
 
Support programmation orientée objet c# .net version f8
Support programmation orientée objet c#  .net version f8Support programmation orientée objet c#  .net version f8
Support programmation orientée objet c# .net version f8
ENSET, Université Hassan II Casablanca
 

What's hot (20)

Base des données réparties
Base des données répartiesBase des données réparties
Base des données réparties
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-Correction
 
Systèmes d'Exploitation - chp1-introduction
Systèmes d'Exploitation - chp1-introductionSystèmes d'Exploitation - chp1-introduction
Systèmes d'Exploitation - chp1-introduction
 
Tp3 - Application SOA avec BPEL
Tp3 - Application SOA avec BPELTp3 - Application SOA avec BPEL
Tp3 - Application SOA avec BPEL
 
Architectures 3-tiers (Web)
Architectures 3-tiers (Web)Architectures 3-tiers (Web)
Architectures 3-tiers (Web)
 
PFE : ITIL - Gestion de parc informatique
PFE : ITIL - Gestion de parc informatiquePFE : ITIL - Gestion de parc informatique
PFE : ITIL - Gestion de parc informatique
 
exercices business intelligence
exercices business intelligence exercices business intelligence
exercices business intelligence
 
Chp2 - Diagramme des Cas d'Utilisation
Chp2 - Diagramme des Cas d'UtilisationChp2 - Diagramme des Cas d'Utilisation
Chp2 - Diagramme des Cas d'Utilisation
 
diagramme de séquence UML
diagramme de séquence UMLdiagramme de séquence UML
diagramme de séquence UML
 
Support de cours Spring M.youssfi
Support de cours Spring  M.youssfiSupport de cours Spring  M.youssfi
Support de cours Spring M.youssfi
 
Middleware
MiddlewareMiddleware
Middleware
 
BigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-ReduceBigData_TP1: Initiation à Hadoop et Map-Reduce
BigData_TP1: Initiation à Hadoop et Map-Reduce
 
Formation JAVA/J2EE
Formation JAVA/J2EEFormation JAVA/J2EE
Formation JAVA/J2EE
 
Chp3 - Modélisation Multidimensionnelle
Chp3 - Modélisation MultidimensionnelleChp3 - Modélisation Multidimensionnelle
Chp3 - Modélisation Multidimensionnelle
 
Introduction aux systèmes répartis
Introduction aux systèmes répartisIntroduction aux systèmes répartis
Introduction aux systèmes répartis
 
Chp1 - Introduction aux méthodologies de Conception
Chp1 - Introduction aux méthodologies de ConceptionChp1 - Introduction aux méthodologies de Conception
Chp1 - Introduction aux méthodologies de Conception
 
Modélisation de données pour MongoDB
Modélisation de données pour MongoDBModélisation de données pour MongoDB
Modélisation de données pour MongoDB
 
Cours Big Data Chap5
Cours Big Data Chap5Cours Big Data Chap5
Cours Big Data Chap5
 
eServices-Tp1: Web Services
eServices-Tp1: Web ServiceseServices-Tp1: Web Services
eServices-Tp1: Web Services
 
Support programmation orientée objet c# .net version f8
Support programmation orientée objet c#  .net version f8Support programmation orientée objet c#  .net version f8
Support programmation orientée objet c# .net version f8
 

Similar to Lab3-DB_Neo4j

Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH) Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
David Fombella Pombal
 
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedNeo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
snehapandey01
 
Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendations
proksik
 
Neo4J Open Source Graph Database
Neo4J Open Source Graph DatabaseNeo4J Open Source Graph Database
Neo4J Open Source Graph Database
Mark Maslyn
 
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
Max De Marzi
 
Introduction to Graphs with Neo4j
Introduction to Graphs with Neo4jIntroduction to Graphs with Neo4j
Introduction to Graphs with Neo4j
Neo4j
 
security in neo4j
security in neo4jsecurity in neo4j
security in neo4j
esmaillhasanzadeh1
 
DBMS CS2
DBMS CS2DBMS CS2
Data science unit3
Data science unit3Data science unit3
Data science unit3
varshakumar21
 
Graphql
GraphqlGraphql
Relational Database & Database Management System
Relational Database & Database Management SystemRelational Database & Database Management System
Relational Database & Database Management System
Nimrakhan89
 
An Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
An Empirical Comparison of Knowledge Graph Embeddings for Item RecommendationAn Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
An Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
Enrico Palumbo
 
Training Week: Introduction to Neo4j
Training Week: Introduction to Neo4jTraining Week: Introduction to Neo4j
Training Week: Introduction to Neo4j
Neo4j
 
Neo4j (Part 1)
Neo4j (Part 1)Neo4j (Part 1)
Neo4j (Part 1)
Bibhuti Regmi
 
The Eprints Application Profile: a FRBR approach to modelling repository meta...
The Eprints Application Profile: a FRBR approach to modelling repository meta...The Eprints Application Profile: a FRBR approach to modelling repository meta...
The Eprints Application Profile: a FRBR approach to modelling repository meta...
Julie Allinson
 
Darshan sem4 140703_ooad_2014 (diagrams)
Darshan sem4 140703_ooad_2014 (diagrams)Darshan sem4 140703_ooad_2014 (diagrams)
Darshan sem4 140703_ooad_2014 (diagrams)
Gajeshwar Bahekar
 
Project
Project Project
Project
SaiRoyals10
 
Ooad unit 1
Ooad unit 1Ooad unit 1
Ooad unit 1
raj kumar
 
Introduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jIntroduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4j
Abdullah Hamidi
 
networkanalysis
networkanalysisnetworkanalysis
networkanalysis
moogway
 

Similar to Lab3-DB_Neo4j (20)

Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH) Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
 
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedNeo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
 
Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendations
 
Neo4J Open Source Graph Database
Neo4J Open Source Graph DatabaseNeo4J Open Source Graph Database
Neo4J Open Source Graph Database
 
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
 
Introduction to Graphs with Neo4j
Introduction to Graphs with Neo4jIntroduction to Graphs with Neo4j
Introduction to Graphs with Neo4j
 
security in neo4j
security in neo4jsecurity in neo4j
security in neo4j
 
DBMS CS2
DBMS CS2DBMS CS2
DBMS CS2
 
Data science unit3
Data science unit3Data science unit3
Data science unit3
 
Graphql
GraphqlGraphql
Graphql
 
Relational Database & Database Management System
Relational Database & Database Management SystemRelational Database & Database Management System
Relational Database & Database Management System
 
An Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
An Empirical Comparison of Knowledge Graph Embeddings for Item RecommendationAn Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
An Empirical Comparison of Knowledge Graph Embeddings for Item Recommendation
 
Training Week: Introduction to Neo4j
Training Week: Introduction to Neo4jTraining Week: Introduction to Neo4j
Training Week: Introduction to Neo4j
 
Neo4j (Part 1)
Neo4j (Part 1)Neo4j (Part 1)
Neo4j (Part 1)
 
The Eprints Application Profile: a FRBR approach to modelling repository meta...
The Eprints Application Profile: a FRBR approach to modelling repository meta...The Eprints Application Profile: a FRBR approach to modelling repository meta...
The Eprints Application Profile: a FRBR approach to modelling repository meta...
 
Darshan sem4 140703_ooad_2014 (diagrams)
Darshan sem4 140703_ooad_2014 (diagrams)Darshan sem4 140703_ooad_2014 (diagrams)
Darshan sem4 140703_ooad_2014 (diagrams)
 
Project
Project Project
Project
 
Ooad unit 1
Ooad unit 1Ooad unit 1
Ooad unit 1
 
Introduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4jIntroduction to graph databases in term of neo4j
Introduction to graph databases in term of neo4j
 
networkanalysis
networkanalysisnetworkanalysis
networkanalysis
 

More from Lilia Sfaxi

chp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdfchp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdf
Lilia Sfaxi
 
Plan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdfPlan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdf
Lilia Sfaxi
 
Lab2-DB-Mongodb
Lab2-DB-MongodbLab2-DB-Mongodb
Lab2-DB-Mongodb
Lilia Sfaxi
 
Lab1-DB-Cassandra
Lab1-DB-CassandraLab1-DB-Cassandra
Lab1-DB-Cassandra
Lilia Sfaxi
 
TP1-UML-Correction
TP1-UML-CorrectionTP1-UML-Correction
TP1-UML-Correction
Lilia Sfaxi
 
TP0-UML-Correction
TP0-UML-CorrectionTP0-UML-Correction
TP0-UML-Correction
Lilia Sfaxi
 
TD4-UML
TD4-UMLTD4-UML
TD4-UML
Lilia Sfaxi
 
TD4-UML-Correction
TD4-UML-CorrectionTD4-UML-Correction
TD4-UML-Correction
Lilia Sfaxi
 
TD3-UML-Séquences
TD3-UML-SéquencesTD3-UML-Séquences
TD3-UML-Séquences
Lilia Sfaxi
 
TD3-UML-Correction
TD3-UML-CorrectionTD3-UML-Correction
TD3-UML-Correction
Lilia Sfaxi
 
TD2 - UML - Correction
TD2 - UML - CorrectionTD2 - UML - Correction
TD2 - UML - Correction
Lilia Sfaxi
 
TD1 - UML - DCU
TD1 - UML - DCUTD1 - UML - DCU
TD1 - UML - DCU
Lilia Sfaxi
 
TD1-UML-correction
TD1-UML-correctionTD1-UML-correction
TD1-UML-correction
Lilia Sfaxi
 
Android - Tp1 - installation et démarrage
Android - Tp1 -   installation et démarrageAndroid - Tp1 -   installation et démarrage
Android - Tp1 - installation et démarrage
Lilia Sfaxi
 
Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques
Lilia Sfaxi
 
Android - Tp3 - intents
Android - Tp3 -  intentsAndroid - Tp3 -  intents
Android - Tp3 - intents
Lilia Sfaxi
 
Android - TPBonus - web services
Android - TPBonus - web servicesAndroid - TPBonus - web services
Android - TPBonus - web services
Lilia Sfaxi
 
Android - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancésAndroid - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancés
Lilia Sfaxi
 
Android - Tp 5 - stockage de données
Android - Tp 5 -  stockage de donnéesAndroid - Tp 5 -  stockage de données
Android - Tp 5 - stockage de données
Lilia Sfaxi
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
Lilia Sfaxi
 

More from Lilia Sfaxi (20)

chp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdfchp1-Intro à l'urbanisation des SI.pdf
chp1-Intro à l'urbanisation des SI.pdf
 
Plan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdfPlan d'études_INSAT_2022_2023.pdf
Plan d'études_INSAT_2022_2023.pdf
 
Lab2-DB-Mongodb
Lab2-DB-MongodbLab2-DB-Mongodb
Lab2-DB-Mongodb
 
Lab1-DB-Cassandra
Lab1-DB-CassandraLab1-DB-Cassandra
Lab1-DB-Cassandra
 
TP1-UML-Correction
TP1-UML-CorrectionTP1-UML-Correction
TP1-UML-Correction
 
TP0-UML-Correction
TP0-UML-CorrectionTP0-UML-Correction
TP0-UML-Correction
 
TD4-UML
TD4-UMLTD4-UML
TD4-UML
 
TD4-UML-Correction
TD4-UML-CorrectionTD4-UML-Correction
TD4-UML-Correction
 
TD3-UML-Séquences
TD3-UML-SéquencesTD3-UML-Séquences
TD3-UML-Séquences
 
TD3-UML-Correction
TD3-UML-CorrectionTD3-UML-Correction
TD3-UML-Correction
 
TD2 - UML - Correction
TD2 - UML - CorrectionTD2 - UML - Correction
TD2 - UML - Correction
 
TD1 - UML - DCU
TD1 - UML - DCUTD1 - UML - DCU
TD1 - UML - DCU
 
TD1-UML-correction
TD1-UML-correctionTD1-UML-correction
TD1-UML-correction
 
Android - Tp1 - installation et démarrage
Android - Tp1 -   installation et démarrageAndroid - Tp1 -   installation et démarrage
Android - Tp1 - installation et démarrage
 
Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques Android - Tp2 - Elements graphiques
Android - Tp2 - Elements graphiques
 
Android - Tp3 - intents
Android - Tp3 -  intentsAndroid - Tp3 -  intents
Android - Tp3 - intents
 
Android - TPBonus - web services
Android - TPBonus - web servicesAndroid - TPBonus - web services
Android - TPBonus - web services
 
Android - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancésAndroid - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancés
 
Android - Tp 5 - stockage de données
Android - Tp 5 -  stockage de donnéesAndroid - Tp 5 -  stockage de données
Android - Tp 5 - stockage de données
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
 

Recently uploaded

(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
Priyanka Aash
 
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptxDublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Kunal Gupta
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
maigasapphire
 
How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...
DianaGray10
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
Zilliz
 
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
Priyanka Aash
 
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
Priyanka Aash
 
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Nicolás Lopéz
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
bellared2
 
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
Priyanka Aash
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Muhammad Ali
 
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
shanihomely
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
BrainSell Technologies
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
Shiv Technolabs
 
Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
Steven Carlson
 
Uncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in LibrariesUncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in Libraries
Brian Pichman
 
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
alexjohnson7307
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
BrainSell Technologies
 
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and DisadvantagesBLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
SAI KAILASH R
 
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptxMAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
janagijoythi
 

Recently uploaded (20)

(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
 
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptxDublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
 
How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...How UiPath Discovery Suite supports identification of Agentic Process Automat...
How UiPath Discovery Suite supports identification of Agentic Process Automat...
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
 
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
 
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
 
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
 
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
(CISOPlatform Summit & SACON 2024) Digital Personal Data Protection Act.pdf
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
 
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
Premium Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service ...
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
 
The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
 
Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
 
Uncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in LibrariesUncharted Together- Navigating AI's New Frontiers in Libraries
Uncharted Together- Navigating AI's New Frontiers in Libraries
 
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
 
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and DisadvantagesBLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
BLOCKCHAIN TECHNOLOGY - Advantages and Disadvantages
 
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptxMAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
 

Lab3-DB_Neo4j

  • 1. CS331 - Database Management Systems Dr. Lilia Sfaxi 17 novembre 2019 Neo4J 1. Graph-based Databases : Neo4J 1.1. Graphs Formally, a graph is a collection of nodes and arcs that connect them. The graphs represent the entities in the form of nodes, and the ways in which these entities are connected in the form of arcs. This structure inspired the graph- oriented databases, because they make it possible to model all types of scenarios. For example, the relationships between Twitter users can be represented in a simpli fi ed way by the following graph: A graph can represent any type of data. - A node is the equivalent of a record - A relation makes it possible to connect nodes, and can be typed - Nodes and relationships can have properties, representing named attributes - A label is a name allowing to organize the nodes in groups NEO4J DR. LILIA SFAXI 1 MedTech
  • 2. The database we will use in this lab is Neo4j . This database uses the Cypher 1 language to represent queries. 1.2.Example The example we will show in this manuscript is taken from the tutorial provided by Neo4j in their site on this link: http://neo4j.com/graphacademy/online- course/ The data we process represents: - Movies with a label : Movie and the properties title, released and tagline - People with a label : Person and the properties name and born - An ACTED_IN relation from an actor to a movie, with a roles property containing the list of character names - A DIRECTED relationship from a director to a fi lm. Activity 1 Launch Neo4J on your browser. The default login/password is neo4j/neo4j (they will ask you to change after fi rst authentication). Create the Movies database given as an example by the tool by following these steps: - Once authenticated and the default password replaced, choose: "Jump Into Code" to start developing. - Click on "Create a Graph" in the "Movie Graph" section as follows: Neo4J: http://neo4j.com/ 1 NEO4J DR. LILIA SFAXI 2
  • 3. - In the window that appears, click on the graph creation code to load it into the editor. Then run it. 1.3.The Cipher Language Nodes (a) Actors (m) Films ( ) Anonymous Node Relations -[r]-> A relation called r (a) –[r]-> (m) Actors having a relation r with movies -[:ACTED_IN]-> The relation is of type ACTED_IN (a)-[:ACTED_IN]->(m) Actors who play in a movie (d)-[:DIRECTED]->(m) The directors of a fi lm Properties of Nodes (m {title : "The Matrix"}) Movie with a property title (a {name: "Keanu Reeves", born : 1964}) Actor with properties name and born NEO4J DR. LILIA SFAXI 3
  • 4. Properties of Relations (a)-[ :ACTED_IN {roles :[« Neo »]}]->(m) Relation ACTED_IN with the propperty roles, which is an array of names Labels Allow to recognize different types of nodes. (a:Person)-[:ACTED_IN]->(m:Movie) A person who has played in a movie 1.4. Cipher queries 1.4.1. Simple read requests Here are some examples of Cipher queries: The fi rst statement returns the value of the property property for all nodes. The second one, returns the values of propertyA and propertyB of each pair of nodes node2 and node1 which are connected by a relation (whatever its nature). To return only nodes connected by a relation of type REL_TYPE: NEO4J DR. LILIA SFAXI 4
  • 5. If the relation in question contains properties that one wishes to read, give it a name (here rel): To indicate a particular type of nodes, use the labels: It is possible to assign an identi fi er to a relation, then return the type of the relation, or its properties: To support by an example, consider the following graph: The query to fi nd all the characters in The Matrix movie is: NEO4J DR. LILIA SFAXI 5
  • 6. Another way is also possible to fi lter the data (instead of the traditional WHERE), by replacing the previous query by: Activity 2. Run the following queries in your editor: - Give all movies where Tom Hanks played - Give the list of all Matrix characters - Give each fi lm its release date 1.4.2. Paths A path is a set of connected nodes and relationships, which can be a pattern. For example : (a) -> (b) -> (c) (a) -> (b) <- (c) Example: To show all actors and directors of all movies: It is also possible to divide the query into several paths, as follows: Or: NEO4J DR. LILIA SFAXI 6
  • 7. The results of previous queries are tables. It is possible to return the entire path, with all the properties of all nodes and relationships involved: If this is too much information, you can just select the nodes of the path: ... or only relationships: Activity 3. Execute the following queries in your editor: - Which directors have played in their own movies? - Give the movies where Keanu Reeves played the role of Neo. - Which actors have already played in the same movie with Tom Hanks, and in which fi lm? - Which actors played in the same movie with Tom Hanks, and with Keanu Reeves? - Who are the characters in the movie "The Matrix"? 1.4.3. Edit a graph with Cipher To add a node to the graph: To add (or modify) properties to an existing node: NEO4J DR. LILIA SFAXI 7
  • 8. To add a relationship between two existing nodes: Activity 4. Run the following queries in your editor: - Create a movie called Mystic River - Add Kevin Bacon as an actor in the movie "Mystic River" with the role "Sean" - Change the role to become "Sean Devine" NEO4J DR. LILIA SFAXI 8