SlideShare uma empresa Scribd logo
1 de 8
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

Bases de Données non relationnelles, NoSQL (Introduction) 1er cours
Bases de Données non relationnelles, NoSQL (Introduction) 1er coursBases de Données non relationnelles, NoSQL (Introduction) 1er cours
Bases de Données non relationnelles, NoSQL (Introduction) 1er coursHatim CHAHDI
 
Chp5 - Applications Android
Chp5 - Applications AndroidChp5 - Applications Android
Chp5 - Applications AndroidLilia Sfaxi
 
Architecture réparties et les services web
Architecture réparties et les services webArchitecture réparties et les services web
Architecture réparties et les services webCHOUAIB EL HACHIMI
 
Conception et Mise en place d'une Application Web SPA pour les établissements...
Conception et Mise en place d'une Application Web SPA pour les établissements...Conception et Mise en place d'une Application Web SPA pour les établissements...
Conception et Mise en place d'une Application Web SPA pour les établissements...Ben Ahmed Zohra
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-CorrectionLilia Sfaxi
 
BigData_Chp3: Data Processing
BigData_Chp3: Data ProcessingBigData_Chp3: Data Processing
BigData_Chp3: Data ProcessingLilia Sfaxi
 
Cours Big Data Chap1
Cours Big Data Chap1Cours Big Data Chap1
Cours Big Data Chap1Amal Abid
 
BigData_Chp1: Introduction à la Big Data
BigData_Chp1: Introduction à la Big DataBigData_Chp1: Introduction à la Big Data
BigData_Chp1: Introduction à la Big DataLilia Sfaxi
 
Conception d’un logiciel de gestion d’imagerie médicale
Conception d’un logiciel de gestion d’imagerie médicaleConception d’un logiciel de gestion d’imagerie médicale
Conception d’un logiciel de gestion d’imagerie médicaleNIYITEGEKA innocent
 
Etude d'une application de gestion d'une bibliothèque numérique
Etude d'une application de gestion d'une bibliothèque numérique Etude d'une application de gestion d'une bibliothèque numérique
Etude d'une application de gestion d'une bibliothèque numérique Georges Amichia
 
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-ReduceLilia Sfaxi
 
eServices-Chp5: Microservices et API Management
eServices-Chp5: Microservices et API ManagementeServices-Chp5: Microservices et API Management
eServices-Chp5: Microservices et API ManagementLilia Sfaxi
 
Cours Base de données relationnelles
Cours Base de données relationnellesCours Base de données relationnelles
Cours Base de données relationnellesAymen Kasmi
 
Cours Big Data Chap2
Cours Big Data Chap2Cours Big Data Chap2
Cours Big Data Chap2Amal Abid
 
BigData_TP3 : Spark
BigData_TP3 : SparkBigData_TP3 : Spark
BigData_TP3 : SparkLilia Sfaxi
 
Conception et implémentation d'un nouveau langage de programmation
Conception et implémentation d'un nouveau langage de programmationConception et implémentation d'un nouveau langage de programmation
Conception et implémentation d'un nouveau langage de programmationAymen Bouein
 
Les modèles NoSQL
Les modèles NoSQLLes modèles NoSQL
Les modèles NoSQLebiznext
 
les style d'architecture
les style d'architecture les style d'architecture
les style d'architecture Mouna Maazoun
 

Mais procurados (20)

Bases de Données non relationnelles, NoSQL (Introduction) 1er cours
Bases de Données non relationnelles, NoSQL (Introduction) 1er coursBases de Données non relationnelles, NoSQL (Introduction) 1er cours
Bases de Données non relationnelles, NoSQL (Introduction) 1er cours
 
Chp5 - Applications Android
Chp5 - Applications AndroidChp5 - Applications Android
Chp5 - Applications Android
 
Architecture réparties et les services web
Architecture réparties et les services webArchitecture réparties et les services web
Architecture réparties et les services web
 
Conception et Mise en place d'une Application Web SPA pour les établissements...
Conception et Mise en place d'une Application Web SPA pour les établissements...Conception et Mise en place d'une Application Web SPA pour les établissements...
Conception et Mise en place d'une Application Web SPA pour les établissements...
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-Correction
 
BigData_Chp3: Data Processing
BigData_Chp3: Data ProcessingBigData_Chp3: Data Processing
BigData_Chp3: Data Processing
 
Cours Big Data Chap1
Cours Big Data Chap1Cours Big Data Chap1
Cours Big Data Chap1
 
BigData_Chp1: Introduction à la Big Data
BigData_Chp1: Introduction à la Big DataBigData_Chp1: Introduction à la Big Data
BigData_Chp1: Introduction à la Big Data
 
Conception d’un logiciel de gestion d’imagerie médicale
Conception d’un logiciel de gestion d’imagerie médicaleConception d’un logiciel de gestion d’imagerie médicale
Conception d’un logiciel de gestion d’imagerie médicale
 
Etude d'une application de gestion d'une bibliothèque numérique
Etude d'une application de gestion d'une bibliothèque numérique Etude d'une application de gestion d'une bibliothèque numérique
Etude d'une application de gestion d'une bibliothèque numérique
 
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
 
noSQL
noSQLnoSQL
noSQL
 
eServices-Chp5: Microservices et API Management
eServices-Chp5: Microservices et API ManagementeServices-Chp5: Microservices et API Management
eServices-Chp5: Microservices et API Management
 
Cours Base de données relationnelles
Cours Base de données relationnellesCours Base de données relationnelles
Cours Base de données relationnelles
 
Cours Big Data Chap2
Cours Big Data Chap2Cours Big Data Chap2
Cours Big Data Chap2
 
BigData_TP3 : Spark
BigData_TP3 : SparkBigData_TP3 : Spark
BigData_TP3 : Spark
 
Conception et implémentation d'un nouveau langage de programmation
Conception et implémentation d'un nouveau langage de programmationConception et implémentation d'un nouveau langage de programmation
Conception et implémentation d'un nouveau langage de programmation
 
Cours Génie Logiciel - Introduction
Cours Génie Logiciel - IntroductionCours Génie Logiciel - Introduction
Cours Génie Logiciel - Introduction
 
Les modèles NoSQL
Les modèles NoSQLLes modèles NoSQL
Les modèles NoSQL
 
les style d'architecture
les style d'architecture les style d'architecture
les style d'architecture
 

Semelhante a 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-convertedsnehapandey01
 
Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendationsproksik
 
Neo4J Open Source Graph Database
Neo4J Open Source Graph DatabaseNeo4J Open Source Graph Database
Neo4J Open Source Graph DatabaseMark 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 Neo4jMax De Marzi
 
Introduction to Graphs with Neo4j
Introduction to Graphs with Neo4jIntroduction to Graphs with Neo4j
Introduction to Graphs with Neo4jNeo4j
 
Relational Database & Database Management System
Relational Database & Database Management SystemRelational Database & Database Management System
Relational Database & Database Management SystemNimrakhan89
 
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 RecommendationEnrico Palumbo
 
Training Week: Introduction to Neo4j
Training Week: Introduction to Neo4jTraining Week: Introduction to Neo4j
Training Week: Introduction to Neo4jNeo4j
 
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
 
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 neo4jAbdullah Hamidi
 
networkanalysis
networkanalysisnetworkanalysis
networkanalysismoogway
 

Semelhante a 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
 

Mais de 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.pdfLilia 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.pdfLilia Sfaxi
 
Lab1-DB-Cassandra
Lab1-DB-CassandraLab1-DB-Cassandra
Lab1-DB-CassandraLilia Sfaxi
 
TP1-UML-Correction
TP1-UML-CorrectionTP1-UML-Correction
TP1-UML-CorrectionLilia Sfaxi
 
TP0-UML-Correction
TP0-UML-CorrectionTP0-UML-Correction
TP0-UML-CorrectionLilia Sfaxi
 
TD4-UML-Correction
TD4-UML-CorrectionTD4-UML-Correction
TD4-UML-CorrectionLilia Sfaxi
 
TD3-UML-Séquences
TD3-UML-SéquencesTD3-UML-Séquences
TD3-UML-SéquencesLilia Sfaxi
 
TD3-UML-Correction
TD3-UML-CorrectionTD3-UML-Correction
TD3-UML-CorrectionLilia Sfaxi
 
TD2 - UML - Correction
TD2 - UML - CorrectionTD2 - UML - Correction
TD2 - UML - CorrectionLilia Sfaxi
 
TD1-UML-correction
TD1-UML-correctionTD1-UML-correction
TD1-UML-correctionLilia Sfaxi
 
Android - Tp1 - installation et démarrage
Android - Tp1 -   installation et démarrageAndroid - Tp1 -   installation et démarrage
Android - Tp1 - installation et démarrageLilia 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 - intentsLilia Sfaxi
 
Android - TPBonus - web services
Android - TPBonus - web servicesAndroid - TPBonus - web services
Android - TPBonus - web servicesLilia Sfaxi
 
Android - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancésAndroid - Tp4 - graphiques avancés
Android - Tp4 - graphiques avancésLilia 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éesLilia Sfaxi
 

Mais de 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
 

Último

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Último (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

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