You are on page 1of 22

GRAPHICAL

MUHAMMAD NAQI KHAN


DATABASES
USING NEO4J
GRAPHICAL
DATABASE
GRAPHICAL DATABASE
VS RELATIONAL
DATABASE
CREATE A GRAPHICAL
DATABASE USING
NEOJ4
ADDING DATA

•Now that the DBMS is running and open, we can start adding our data in my
case I will be adding information about my family.
•Code :
•create(bn1:Person{maBN:1, name:"Safeer Khan", height: "5.8", job: "Prof",
Home: "Pakistan" ,SEX : "M"})
•create(bn2:Person{maBN:2, name:"Shazia Safeer", height: "5.2", job: "House
Wife", Home: "Pakistan",SEX : "F"})
•create(bn3:Person{maBN:3, name:"Massoma Safeer", height: "5.2", job:
"Aerospace Engineer", Home: "USA",SEX : "F"})
•create(bn4:Person{maBN:4, name:"Zuhair Khan", height: "5.8", job:
"Automation Engineer", Home: "USA",SEX : "M"})
•create(bn5:Person{maBN:5, name:"Muhammad Naqi Khan", height: "6.0", job:
"Student", Home: "USA",SEX : "M"})
•create(bn6:Person{maBN:6, name:"Saqib Khan", height: "6.0", job:
"Automation Engineer", Home: "Pakistan",SEX : "M"})
•create(bn7:Person{maBN:7, name:"Saba Khan", height: "5.2", job: "Designer",
Home: "USA",SEX : "F"})
•create(bn8:Person{maBN:8, name:"Ali Madhai", height: "5.8", job: "Black
Smith", Home: "Pakistan",SEX : "M"})
•create(bn9:Person{maBN:9, name:"Ail Khan", height: "3.0", job: "STUDENT",
Home: "USA",SEX : "M"})
•create(bn10:Person{maBN:10, name:"Zreena Madhai", height: "5.0", job:
"Housewife", Home: "Pakistan",SEX : "F"})
PARENT OF

•MATCH (a:Person ),(b:Person ),(c:Person ),(d:Person ),


(e:Person )
•WHERE a.name contains "Safeer Khan" AND b.name
contains "Shazia Safeer" AND c.name contains "Massoma
Safeer" AND d.name contains "Zuhair Khan" AND e.name
contains "Muhammad Naqi Khan"
•CREATE (a)-[:PARENT_OF {type: "natural"}]->(c)
•CREATE (b)-[:PARENT_OF {type: "natural"}]->(c)
•CREATE (a)-[:PARENT_OF {type: "natural"}]->(e)
•CREATE (b)-[:PARENT_OF {type: "natural"}]->(e)
•CREATE (a)-[:PARENT_OF {type: "natural"}]->(d)
•CREATE (b)-[:PARENT_OF {type: "natural"}]->(d)
•RETURN a,b,c,d,e
SPOUSE_OF

•MATCH (a:Person ),(b:Person )


•WHERE a.name contains
"Safeer Khan" AND b.name
contains "Shazia Safeer"
•CREATE (a)-[:SPOUSE_OF
{type: "married"}]->(b)
•CREATE (b)-[:SPOUSE_OF
{type: "married"}]->(a)
•RETURN a,b
SPOUSE_OF

•MATCH (a:Person ),(b:Person )


•WHERE a.name contains
"Saqib Khan" AND b.name
contains "Massoma Safeer"
•CREATE (a)-[:SPOUSE_OF
{type: "married"}]->(b)
•CREATE (b)-[:SPOUSE_OF
{type: "married"}]->(a)
•RETURN a,b 
SPOUSE_OF

•MATCH (a:Person ),(b:Person )


•WHERE a.name contains
"Zuhair Khan" AND b.name
contains "Saba Khan"
•CREATE (a)-[:SPOUSE_OF
{type: "married"}]->(b)
•CREATE (b)-[:SPOUSE_OF
{type: "married"}]->(a)
•RETURN a,b
SPOUSE_OF

•MATCH (a:Person ),(b:Person )


•WHERE a.name contains "Ali
Madhai" AND b.name contains
"Zreena Madhai"
•CREATE (a)-[:SPOUSE_OF
{type: "married"}]->(b)
•CREATE (b)-[:SPOUSE_OF
{type: "married"}]->(a)
•RETURN a,b
CHILD_OF

•MATCH (a:Person ),(b:Person ),


(c:Person)
•WHERE a.name contains "Saqib
Khan" AND b.name contains
"Massoma Safeer" AND c.name
contains "Ail Khan"
•CREATE (c)-[:CHILD_OF {type:
"natural"}]->(b)
•CREATE (c)-[:CHILD_OF {type:
"natural"}]->(a)
•RETURN a,b,c
GRAND_PARENT_OF

•MATCH (a:Person ),(b:Person ),(c:Person ),(d:Person ),


(e:Person )
•WHERE a.name contains "Zreena Madhai" AND b.name
contains "Ali Madhai" AND c.name contains "Massoma Safeer"
AND d.name contains "Zuhair Khan" AND e.name contains
"Muhammad Naqi Khan"
•CREATE (a)-[:GRAND_PARENT_OF {type: "natural"}]->(c)
•CREATE (b)-[:GRAND_PARENT_OF {type: "natural"}]->(c)
•CREATE (a)-[:GRAND_PARENT_OF {type: "natural"}]->(e)
•CREATE (b)-[:GRAND_PARENT_OF {type: "natural"}]->(e)
•CREATE (a)-[:GRAND_PARENT_OF {type: "natural"}]->(d)
•CREATE (b)-[:GRAND_PARENT_OF {type: "natural"}]->(d)
•RETURN a,b,c,d,e
GRAND_PARENT_OF

•MATCH (a:Person ),(b:Person ),


(c:Person )
•WHERE a.name contains "Safeer
Khan" AND b.name contains "Shazia
Safeer" And c.name contains "Ail Khan"
•CREATE (a)-[:GRAND_PARENT_OF
{type: "natural"}]->(c)
•CREATE (b)-[:GRAND_PARENT_OF
{type: "natural"}]->(c)
•RETURN a,b,c
SISTER_IN_LAW

•MATCH (a:Person ),(b:Person ),


(c:Person )
•WHERE a.name contains "Massoma
Safeer" AND b.name contains
"Muhammad Naqi Khan" AND
c.name contains "Saba Khan"
•CREATE (c)-[:SISTER_IN_LAW
{type: "natural"}]->(a)
•CREATE (c)-[:SISTER_IN_LAW
{type: "natural"}]->(b)
•RETURN a,b,c
BROTHER_IN_LA
W
•MATCH (a:Person ),(b:Person ),
(c:Person )
•WHERE a.name contains "Zuhair
Khan" AND b.name contains
"Muhammad Naqi Khan" AND
c.name contains "Saqib Khan"
•CREATE (c)-[:Brother_IN_LAW
{type: "natural"}]->(a)
•CREATE (c)-[:Brother_IN_LAW
{type: "natural"}]->(b)
•RETURN a,b,c
PARENT_OF

•MATCH (a:Person ),(b:Person ),


(c:Person )
•WHERE a.name contains "Ali
Madhai" AND b.name contains
"Zreena Madhai" AND c.name
contains "Shazia Safeer"
•CREATE (a)-[:PARENT_OF {type:
"natural"}]->(c)
•CREATE (b)-[:PARENT_OF {type:
"natural"}]->(c)
•RETURN a,b,c
ALL
RELATIONSHIP
S
CONCLUSION
REFERENCES

•What is a graph database? - developer guides. (n.d.). Retrieved April 11, 2021, from

https://neo4j.com/developer/graph-database/

• Retail. Neo4j Graph Database Platform. (2021, June 1). https://neo4j.com/use-cases/retail/.


REVIEW

What did you learn from this topic?


 This topic clearly explains of what graph databases are, the differences between graph
databases and relational databases. Many examples were shown on how to create a graph
databases. Major topics like nodes, relationships were clearly explained by the author.

Was it interesting and why?


 This topic is very interesting because of the growing popularity of graph databases. They are
very flexible when compared to traditional databases. The visual representation of graph
databases is so flexible that they give a clear picture of all the entities, their relationships etc.,
REVIEW

Identify 5 interesting ideas or fact that was missing from the video with reference.
 The use of graph databases in real-time scenarios like fraud detection, recommendation systems is very
interesting.
 A quick implementation of showing how create to a graph database in neo4j would have been very interesting to
watch
 Neo4j offers granular security, Adding some point on what and how security measures can be implemented in neo
4j will be a plus.
 Different types of graphs are available in neo4j – directed graph, undirected graph, graphs with weight. The video
only considers directed graph. It would be interesting to see an example on each type of graph
 A clear explanation on how sql search for result set when a query is given vs how a graph database makes its
search would be very fascinating.
REVIEW

Can you identify another example that could have been used to enhance the topic?
 The video is mainly concentrates on directed graph. All the examples shown in the video
belong to directed graphs. An example about undirected graph like representing various
prominent people in a topic can enhance the topic

Did you find any future research potential?


 Yes, this topic has a great scope for research. Neo4j is implemented in various real time
scenarios like fraud detection, recommender systems etc., research can be carried in these
directions.

You might also like