KEMBAR78
Neo4j Graph Creation Guide | PDF | Data Management Software | Operations Research
0% found this document useful (0 votes)
18 views4 pages

Neo4j Graph Creation Guide

Uploaded by

JADEN JOSEPH
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)
18 views4 pages

Neo4j Graph Creation Guide

Uploaded by

JADEN JOSEPH
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/ 4

Neo4j Graph Creation Guide

how can perform this in neo4j explain the complete code and how will i perform in easiest
explaination

To create this graph structure in Neo4j, you’ll need to define nodes for each person and subject, and
relationships to show that a person is studying a subject. Here’s a simple guide to doing this in Neo4j.

Step-by-Step Guide

1. Open Neo4j Browser

1. Start your Neo4j server and open the Neo4j Browser.

2. Define Nodes and Relationships

To replicate the graph in your screenshot, you’ll need to create two types of nodes:

`Person` nodes (e.g., Eric, Cassie, Annie, etc.)


`Subject` nodes (e.g., Cyber Laws, Disaster Management)

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 1/4
3. Cypher Query to Create Nodes and Relationships

Here’s the Cypher code to create the nodes and relationships you need.

cypher

// Create Person nodes


CREATE (:Person {name: 'Eric'});
CREATE (:Person {name: 'Cassie'});
CREATE (:Person {name: 'Annie'});
CREATE (:Person {name: 'Deborah'});
CREATE (:Person {name: 'Ben'});

// Create Subject nodes


CREATE (:Subject {name: 'Cyber Laws'});
CREATE (:Subject {name: 'Disaster Management'});

// Create STUDYING relationships


MATCH (p:Person {name: 'Eric'}), (s:Subject {name: 'Cyber Laws'})
CREATE (p)-[:STUDYING]->(s);

MATCH (p:Person {name: 'Cassie'}), (s:Subject {name: 'Cyber Laws'})


CREATE (p)-[:STUDYING]->(s);

MATCH (p:Person {name: 'Annie'}), (s:Subject {name: 'Cyber Laws'})


CREATE (p)-[:STUDYING]->(s);

MATCH (p:Person {name: 'Deborah'}), (s:Subject {name: 'Disaster Management'})


CREATE (p)-[:STUDYING]->(s);

MATCH (p:Person {name: 'Ben'}), (s:Subject {name: 'Disaster Management'})


CREATE (p)-[:STUDYING]->(s);

Explanation of the Code

1. Creating Person Nodes: The first five lines create individual `Person` nodes for Eric, Cassie,
Annie, Deborah, and Ben.

2. Creating Subject Nodes: The next two lines create `Subject` nodes for Cyber Laws and Disaster
Management.

3. Creating STUDYING Relationships:


The `MATCH` clause finds a `Person` and a `Subject` by name.
The `CREATE` clause then creates a relationship between them labeled as `STUDYING`.

4. Run the Code in Neo4j Browser

1. Copy the Cypher code.


2. Paste it into the Neo4j Browser.
3. Press Enter to execute it.

5. View the Graph

After running the code, click on the graph icon in the Neo4j Browser to visualize the connections
between nodes, similar to the image in your screenshot. You can adjust the layout by dragging nodes
around to match the arrangement you want.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 2/4
code ka ek ek line apun ki bhasha meh samja

Bilkul! Chalo line-by-line code ko apun ki bhasha mein todte hain. Ye code Neo4j mein Cypher query
language ka istemal karta hai jo humari graph database mein nodes aur relationships banata hai.

Code aur Samjhaayein

cypher

// Create Person nodes


CREATE (:Person {name: 'Eric'});
CREATE (:Person {name: 'Cassie'});
CREATE (:Person {name: 'Annie'});
CREATE (:Person {name: 'Deborah'});
CREATE (:Person {name: 'Ben'});

1. CREATE (
{name: 'Eric'});

Yahan pe `CREATE` ka matlab hai “neo bhai, ek naya node bana”.


`:Person` ka tag daal diya matlab yeh node `Person` category ka hai.
`{name: 'Eric'}` ye properties hain. Yahan hum `name` ka attribute daal rahe hain, aur uska
value `Eric` hai.
Ye line Eric naam ka ek banda banata hai jo `Person` type ka hai.

2. Baaki ki lines same kaam karti hain, bas `name` ka value alag hai. Yeh alag-alag logon ke nodes
create kar rahi hain: Cassie, Annie, Deborah, aur Ben.

cypher

// Create Subject nodes


CREATE (:Subject {name: 'Cyber Laws'});
CREATE (:Subject {name: 'Disaster Management'});

3. CREATE (
{name: 'Cyber Laws'});

Ye bhi waise hi kaam karta hai jaisa pehle kiya tha.


Bas `:Subject` tag hai jo ye batata hai ke yeh node ek `Subject` type ka hai.
`{name: 'Cyber Laws'}` isme subject ka naam hai `Cyber Laws`.
Yeh line Cyber Laws naam ka ek subject ka node banata hai.

4. Dusri line Disaster Management naam ka subject banati hai. Toh ab humare paas do subjects
hain: Cyber Laws aur Disaster Management.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 3/4
cypher

// Create STUDYING relationships


MATCH (p:Person {name: 'Eric'}), (s:Subject {name: 'Cyber Laws'})
CREATE (p)-[:STUDYING]->(s);

5. MATCH (p
{name: 'Eric'}), (s
{name: 'Cyber Laws'})

`MATCH` ka matlab hai "neo bhai, pehle se bane hue nodes dhundke laa".
`(p:Person {name: 'Eric'})` yahan hum `Person` type ka node dhund rahe hain jiska naam
`Eric` hai, aur use `p` naam ka variable de diya.
`(s:Subject {name: 'Cyber Laws'})` yahan hum `Subject` type ka node dhund rahe hain
jiska naam `Cyber Laws` hai, aur use `s` naam ka variable de diya.

6. CREATE (p)-[
]->(s);

Ab hum `p` aur `s` ke beech mein ek relationship bana rahe hain.
`(p)-[:STUDYING]->(s)` yahan pe `p` se `s` ke taraf ek arrow hai jo `STUDYING` relationship
dikhata hai.
Matlab, `Eric` Cyber Laws `study` kar raha hai.

7. Baaki ke relationships waise hi kaam karte hain bas alag-alag logon aur subjects ke beech mein
`STUDYING` ka relationship banate hain.

Aur Lines

cypher

MATCH (p:Person {name: 'Cassie'}), (s:Subject {name: 'Cyber Laws'})


CREATE (p)-[:STUDYING]->(s);

MATCH (p:Person {name: 'Annie'}), (s:Subject {name: 'Cyber Laws'})


CREATE (p)-[:STUDYING]->(s);

MATCH (p:Person {name: 'Deborah'}), (s:Subject {name: 'Disaster Management'})


CREATE (p)-[:STUDYING]->(s);

MATCH (p:Person {name: 'Ben'}), (s:Subject {name: 'Disaster Management'})


CREATE (p)-[:STUDYING]->(s);

Har ek `MATCH` aur `CREATE` pair alag-alag student aur subject ke beech `STUDYING` relationship
banata hai.
Example: Cassie aur Cyber Laws ke beech mein, Annie aur Cyber Laws ke beech mein, etc.

Ye code run karne ke baad tu Neo4j Browser pe jaake dekh sakta hai apne sabhi log aur unke subjects
ke beech ke connections, aur bas tera graph taiyaar hai!
ChatGPT can make mistakes. Check important info.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 4/4

You might also like