SlideShare a Scribd company logo

Lab3-DB_Neo4j

Lilia Sfaxi
Lilia Sfaxi
Lilia SfaxiDocteur-Ingénieur en Informatique - Assistante à l'INSAT

Lab about the NOSQL Database Neo4J

Lab3-DB_Neo4j

1 of 8
Download to read 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

Recommended

Android-Tp3: fragments et menus
Android-Tp3: fragments et menusAndroid-Tp3: fragments et menus
Android-Tp3: fragments et menusLilia Sfaxi
 
BigData_TP5 : Neo4J
BigData_TP5 : Neo4JBigData_TP5 : Neo4J
BigData_TP5 : Neo4JLilia Sfaxi
 
Chp3 - Architecture Logicielle des Applications Mobiles
Chp3 - Architecture Logicielle des Applications MobilesChp3 - Architecture Logicielle des Applications Mobiles
Chp3 - Architecture Logicielle des Applications MobilesLilia Sfaxi
 
BigData_TP3 : Spark
BigData_TP3 : SparkBigData_TP3 : Spark
BigData_TP3 : SparkLilia Sfaxi
 

More Related Content

What's hot

La spécification des besoins
La spécification des besoinsLa spécification des besoins
La spécification des besoinsIsmahen Traya
 
Chp2 - Conception UX-UI des Applications Mobiles
Chp2 - Conception UX-UI des Applications MobilesChp2 - Conception UX-UI des Applications Mobiles
Chp2 - Conception UX-UI des Applications MobilesLilia Sfaxi
 
Les Streams de Java 8
Les Streams de Java 8Les Streams de Java 8
Les Streams de Java 8Antoine Rey
 
Diagrammes de classes uml
Diagrammes de classes umlDiagrammes de classes uml
Diagrammes de classes umlmeriem sari
 
Android-Tp5 : web services
Android-Tp5 : web servicesAndroid-Tp5 : web services
Android-Tp5 : web servicesLilia Sfaxi
 
Tp1 - Initiation à Java-Eclipse
Tp1 - Initiation à Java-EclipseTp1 - Initiation à Java-Eclipse
Tp1 - Initiation à Java-EclipseLilia Sfaxi
 
UML Part 4- diagrammres de classes et d'objets mansouri
UML Part 4- diagrammres de classes et d'objets mansouriUML Part 4- diagrammres de classes et d'objets mansouri
UML Part 4- diagrammres de classes et d'objets mansouriMansouri Khalifa
 
Diagramme des cas d’utilisation.pdf
 Diagramme des cas d’utilisation.pdf Diagramme des cas d’utilisation.pdf
Diagramme des cas d’utilisation.pdfYasushiTsubakik
 
Chp5 - Applications Android
Chp5 - Applications AndroidChp5 - Applications Android
Chp5 - Applications AndroidLilia Sfaxi
 
BigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-ReduceBigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-ReduceLilia Sfaxi
 
Big Data, Hadoop & Spark
Big Data, Hadoop & SparkBig Data, Hadoop & Spark
Big Data, Hadoop & SparkAlexia Audevart
 
BigData_Chp3: Data Processing
BigData_Chp3: Data ProcessingBigData_Chp3: Data Processing
BigData_Chp3: Data ProcessingLilia Sfaxi
 
BigData_Chp4: NOSQL
BigData_Chp4: NOSQLBigData_Chp4: NOSQL
BigData_Chp4: NOSQLLilia Sfaxi
 
Android-Tp4: stockage
Android-Tp4: stockageAndroid-Tp4: stockage
Android-Tp4: stockageLilia Sfaxi
 
Android-Tp2: liste et adaptateurs
Android-Tp2: liste et adaptateursAndroid-Tp2: liste et adaptateurs
Android-Tp2: liste et adaptateursLilia Sfaxi
 
Examen sybase - Administration base de donnees
Examen sybase - Administration base de donneesExamen sybase - Administration base de donnees
Examen sybase - Administration base de donneeswebreaker
 
Chp1 - Introduction au Développement Mobile
Chp1 - Introduction au Développement MobileChp1 - Introduction au Développement Mobile
Chp1 - Introduction au Développement MobileLilia Sfaxi
 

What's hot (20)

La spécification des besoins
La spécification des besoinsLa spécification des besoins
La spécification des besoins
 
Chp2 - Conception UX-UI des Applications Mobiles
Chp2 - Conception UX-UI des Applications MobilesChp2 - Conception UX-UI des Applications Mobiles
Chp2 - Conception UX-UI des Applications Mobiles
 
Les Streams de Java 8
Les Streams de Java 8Les Streams de Java 8
Les Streams de Java 8
 
Corrige tp java
Corrige tp javaCorrige tp java
Corrige tp java
 
Diagrammes de classes uml
Diagrammes de classes umlDiagrammes de classes uml
Diagrammes de classes uml
 
Android-Tp5 : web services
Android-Tp5 : web servicesAndroid-Tp5 : web services
Android-Tp5 : web services
 
Tp1 - Initiation à Java-Eclipse
Tp1 - Initiation à Java-EclipseTp1 - Initiation à Java-Eclipse
Tp1 - Initiation à Java-Eclipse
 
UML Part 4- diagrammres de classes et d'objets mansouri
UML Part 4- diagrammres de classes et d'objets mansouriUML Part 4- diagrammres de classes et d'objets mansouri
UML Part 4- diagrammres de classes et d'objets mansouri
 
Diagramme des cas d’utilisation.pdf
 Diagramme des cas d’utilisation.pdf Diagramme des cas d’utilisation.pdf
Diagramme des cas d’utilisation.pdf
 
Chp5 - Applications Android
Chp5 - Applications AndroidChp5 - Applications Android
Chp5 - Applications Android
 
BigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-ReduceBigData_Chp2: Hadoop & Map-Reduce
BigData_Chp2: Hadoop & Map-Reduce
 
Big Data, Hadoop & Spark
Big Data, Hadoop & SparkBig Data, Hadoop & Spark
Big Data, Hadoop & Spark
 
BigData_Chp3: Data Processing
BigData_Chp3: Data ProcessingBigData_Chp3: Data Processing
BigData_Chp3: Data Processing
 
BigData_Chp4: NOSQL
BigData_Chp4: NOSQLBigData_Chp4: NOSQL
BigData_Chp4: NOSQL
 
Android-Tp4: stockage
Android-Tp4: stockageAndroid-Tp4: stockage
Android-Tp4: stockage
 
Android-Tp2: liste et adaptateurs
Android-Tp2: liste et adaptateursAndroid-Tp2: liste et adaptateurs
Android-Tp2: liste et adaptateurs
 
Examen sybase - Administration base de donnees
Examen sybase - Administration base de donneesExamen sybase - Administration base de donnees
Examen sybase - Administration base de donnees
 
Uml classes Par les exemples
Uml classes Par les exemplesUml classes Par les exemples
Uml classes Par les exemples
 
Chp1 - Introduction au Développement Mobile
Chp1 - Introduction au Développement MobileChp1 - Introduction au Développement Mobile
Chp1 - Introduction au Développement Mobile
 
Tp n 3 linux
Tp n 3 linuxTp n 3 linux
Tp n 3 linux
 

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

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.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
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-CorrectionLilia 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
 

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
 
Lab1-DB-Cassandra
Lab1-DB-CassandraLab1-DB-Cassandra
Lab1-DB-Cassandra
 
TP2-UML-Correction
TP2-UML-CorrectionTP2-UML-Correction
TP2-UML-Correction
 
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-Classes
TD2-UML-ClassesTD2-UML-Classes
TD2-UML-Classes
 
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
 

Recently uploaded

2024 February Patch Tuesday
2024 February Patch Tuesday2024 February Patch Tuesday
2024 February Patch TuesdayIvanti
 
Microsoft Azure News - Feb 2024
Microsoft Azure News - Feb 2024Microsoft Azure News - Feb 2024
Microsoft Azure News - Feb 2024Daniel Toomey
 
Q1 Memory Fabric Forum: SMART CXL Product Lineup
Q1 Memory Fabric Forum: SMART CXL Product LineupQ1 Memory Fabric Forum: SMART CXL Product Lineup
Q1 Memory Fabric Forum: SMART CXL Product LineupMemory Fabric Forum
 
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERNRonnelBaroc
 
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre..."Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...shaiyuvasv
 
2) Presentation_Overview_ISO_16140-3_Method_verification_20210322.pptx
2) Presentation_Overview_ISO_16140-3_Method_verification_20210322.pptx2) Presentation_Overview_ISO_16140-3_Method_verification_20210322.pptx
2) Presentation_Overview_ISO_16140-3_Method_verification_20210322.pptxssuser796efb
 
Q1 Memory Fabric Forum: XConn CXL Switches for AI
Q1 Memory Fabric Forum: XConn CXL Switches for AIQ1 Memory Fabric Forum: XConn CXL Switches for AI
Q1 Memory Fabric Forum: XConn CXL Switches for AIMemory Fabric Forum
 
Q1 Memory Fabric Forum: Advantages of Optical CXL​ for Disaggregated Compute ...
Q1 Memory Fabric Forum: Advantages of Optical CXL​ for Disaggregated Compute ...Q1 Memory Fabric Forum: Advantages of Optical CXL​ for Disaggregated Compute ...
Q1 Memory Fabric Forum: Advantages of Optical CXL​ for Disaggregated Compute ...Memory Fabric Forum
 
My sample product research idea for you!
My sample product research idea for you!My sample product research idea for you!
My sample product research idea for you!KivenRaySarsaba
 
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI.pdf
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI.pdfLLMs, LMMs, their Improvement Suggestions and the Path towards AGI.pdf
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI.pdfThomas Poetter
 
AWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS Chicago
 
Manual Eurotronic Thermostatic Valve Comry Z-Wave
Manual Eurotronic Thermostatic Valve Comry Z-WaveManual Eurotronic Thermostatic Valve Comry Z-Wave
Manual Eurotronic Thermostatic Valve Comry Z-WaveDomotica daVinci
 
Navigating the Never Normal Strategies for Portfolio Leaders
Navigating the Never Normal Strategies for Portfolio LeadersNavigating the Never Normal Strategies for Portfolio Leaders
Navigating the Never Normal Strategies for Portfolio LeadersOnePlan Solutions
 
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!XfilesPro
 
Importance of magazines in education ppt
Importance of magazines in education pptImportance of magazines in education ppt
Importance of magazines in education pptsafnarafeek2002
 
Azure Migration Guide for IT Professionals
Azure Migration Guide for IT ProfessionalsAzure Migration Guide for IT Professionals
Azure Migration Guide for IT ProfessionalsChristine Shepherd
 
Introduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxIntroduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxBrandon Minnick, MBA
 
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdfZ-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdfDomotica daVinci
 
zigbee motion sensor user manual NAS-PD07B2.pdf
zigbee motion sensor user manual NAS-PD07B2.pdfzigbee motion sensor user manual NAS-PD07B2.pdf
zigbee motion sensor user manual NAS-PD07B2.pdfDomotica daVinci
 

Recently uploaded (20)

2024 February Patch Tuesday
2024 February Patch Tuesday2024 February Patch Tuesday
2024 February Patch Tuesday
 
Microsoft Azure News - Feb 2024
Microsoft Azure News - Feb 2024Microsoft Azure News - Feb 2024
Microsoft Azure News - Feb 2024
 
Q1 Memory Fabric Forum: SMART CXL Product Lineup
Q1 Memory Fabric Forum: SMART CXL Product LineupQ1 Memory Fabric Forum: SMART CXL Product Lineup
Q1 Memory Fabric Forum: SMART CXL Product Lineup
 
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
 
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre..."Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
 
2) Presentation_Overview_ISO_16140-3_Method_verification_20210322.pptx
2) Presentation_Overview_ISO_16140-3_Method_verification_20210322.pptx2) Presentation_Overview_ISO_16140-3_Method_verification_20210322.pptx
2) Presentation_Overview_ISO_16140-3_Method_verification_20210322.pptx
 
Q1 Memory Fabric Forum: XConn CXL Switches for AI
Q1 Memory Fabric Forum: XConn CXL Switches for AIQ1 Memory Fabric Forum: XConn CXL Switches for AI
Q1 Memory Fabric Forum: XConn CXL Switches for AI
 
Q1 Memory Fabric Forum: Advantages of Optical CXL​ for Disaggregated Compute ...
Q1 Memory Fabric Forum: Advantages of Optical CXL​ for Disaggregated Compute ...Q1 Memory Fabric Forum: Advantages of Optical CXL​ for Disaggregated Compute ...
Q1 Memory Fabric Forum: Advantages of Optical CXL​ for Disaggregated Compute ...
 
My sample product research idea for you!
My sample product research idea for you!My sample product research idea for you!
My sample product research idea for you!
 
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI.pdf
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI.pdfLLMs, LMMs, their Improvement Suggestions and the Path towards AGI.pdf
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI.pdf
 
AWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user group
 
Manual Eurotronic Thermostatic Valve Comry Z-Wave
Manual Eurotronic Thermostatic Valve Comry Z-WaveManual Eurotronic Thermostatic Valve Comry Z-Wave
Manual Eurotronic Thermostatic Valve Comry Z-Wave
 
COE AI Lab Universities
COE AI Lab UniversitiesCOE AI Lab Universities
COE AI Lab Universities
 
Navigating the Never Normal Strategies for Portfolio Leaders
Navigating the Never Normal Strategies for Portfolio LeadersNavigating the Never Normal Strategies for Portfolio Leaders
Navigating the Never Normal Strategies for Portfolio Leaders
 
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
 
Importance of magazines in education ppt
Importance of magazines in education pptImportance of magazines in education ppt
Importance of magazines in education ppt
 
Azure Migration Guide for IT Professionals
Azure Migration Guide for IT ProfessionalsAzure Migration Guide for IT Professionals
Azure Migration Guide for IT Professionals
 
Introduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxIntroduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptx
 
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdfZ-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
 
zigbee motion sensor user manual NAS-PD07B2.pdf
zigbee motion sensor user manual NAS-PD07B2.pdfzigbee motion sensor user manual NAS-PD07B2.pdf
zigbee motion sensor user manual NAS-PD07B2.pdf
 

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