0% found this document useful (0 votes)
23 views3 pages

INS Assignments

Graph databases are particularly useful in scenarios with interconnected data, such as social networks, recommendation systems, and fraud detection. They enable efficient modeling of relationships and data traversal through operations like creating, reading, updating, and deleting nodes and relationships using Cypher queries in Neo4j. Examples of applications include healthcare research, supply chain management, and identity management.

Uploaded by

kariyasneha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

INS Assignments

Graph databases are particularly useful in scenarios with interconnected data, such as social networks, recommendation systems, and fraud detection. They enable efficient modeling of relationships and data traversal through operations like creating, reading, updating, and deleting nodes and relationships using Cypher queries in Neo4j. Examples of applications include healthcare research, supply chain management, and identity management.

Uploaded by

kariyasneha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment-4

1. Identify real-world scenarios where graph databases are beneficial, such


as social networks, recommendation systems, and fraud detection.
Ans = Graph databases are highly beneficial in scenarios where data is highly
interconnected and relationships between entities are crucial.
Some real-world applications include:
1.Social Networks – Model relationships, find mutual friends, and detect communities
(e.g., Facebook, LinkedIn).
2.Recommendation Systems – Suggest products/movies based on user interactions
(e.g., Amazon, Netflix).
3.Fraud Detection – Identify suspicious transactions by analyzing account connections
(e.g., banking, credit cards).
4.Network & IT Management – Monitor and secure complex networks (e.g.,
cybersecurity, telecom).
5.Healthcare & Research – Map relationships between diseases, genes, and
treatments (e.g., drug discovery, genomics).
6.Supply Chain & Logistics – Track shipments, optimize delivery routes, and manage
supplier relationships efficiently (e.g., FedEx, Amazon Logistics).
7.Knowledge Graphs & Semantic Search – Enhance search engines by
understanding relationships between concepts (e.g., Google Knowledge Graph).
8.Identity & Access Management (IAM) – Manage user roles, permissions, and
access control in organizations (e.g., enterprise security systems).

2. Write Cypher queries to perform basic CRUD operations and traverse


the graph in Neo4j.
Ans =
1. Create Nodes and Relationships (CREATE)
CREATE (a:Person {name: 'Alice', age: 25})
CREATE (b:Person {name: 'Bob', age: 30})
CREATE (a)-[:FRIEND]->(b)
RETURN a, b;
This creates two Person nodes and a FRIEND relationship between them.
2. Read Data (MATCH)
a) Retrieve all persons:
MATCH (p:Person) RETURN p;
3. Update Nodes (SET)
a) Update Alice’s age:
MATCH (a:Person {name: 'Alice'})
SET a.age = 26
RETURN a;
4. Delete Nodes and Relationships (DELETE)
a) Delete a node (only if it has no relationships):
MATCH (a:Person {name: 'Alice'})
DELETE a;

3.Perform basic graph operations in Neo4j, such as creating nodes and


relationships, updating properties, and deleting elements.
Ans =
1. Creating Nodes and Relationships
a) Create Nodes
CREATE (a:Person {name: 'Alice', age: 25});
CREATE (b:Person {name: 'Bob', age: 30});
RETURN a, b;
b) Create a Relationship
MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
CREATE (a)-[:FRIEND]->(b)
RETURN a, b;
2. Reading Data
a) Retrieve All Nodes
MATCH (n) RETURN n;
b) Find Alice’s Friends
MATCH (a:Person {name: 'Alice'})-[:FRIEND]->(friend)
RETURN friend;
3. Updating Properties
a) Update Alice’s Age
MATCH (a:Person {name: 'Alice'})
SET a.age = 26
RETURN a;
b) Add a New Property
MATCH (a:Person {name: 'Alice'})
SET a.city = 'New York'
RETURN a;
4. Deleting Elements
a) Delete a Relationship

MATCH (a:Person {name: 'Alice'})-[r:FRIEND]->(b:Person {name: 'Bob'})


DELETE r;
b) Delete a Node (Only If It Has No Relationships)
MATCH (a:Person {name: 'Alice'})
DELETE a;
c) Delete a Node and Its Relationships
MATCH (a:Person {name: 'Alice'})
DETACH DELETE a;

You might also like