# Neo4J Components

Nodes

Labels

Properties

Relationships

Unlike MySQL, you don't create Tables / Schemas first. You start creating the actual Node (Datapoint).

### **Node**

```
// Create a single Node

create (n)

match(t) return t

create (anything),(seriously_anything)

match(e) return e
```

### Label

```
// Node with Label

create(n:Student)

match(y) return y
```

Label every node. Nodes without Labels are not useful.

```
// To name a Node after Creation. Example ID=2 set Label to Building

match(n) where ID(n)=2 set t:somelabel

// To rename a Label

match(n) where ID(n)=2 set t:Building remove t:somelabel 

match(n) return n
```

Remember Algebra?  we always find x? Why it's always x?

In the same way, in Neo4J, the **node** is called n.

### **Properties**

```
create (n:Book{title:"The Sapiens", author:"Yuval Noah"});

create (n:Book{title:"Who Moved My Cheese", author:"Johnson M.D"});

// Set Property for node which doesnt have Property
match(t) where ID(t)=2 set t.name="RobinsonHall" return t

// show all nodes

match(t) return t
```

### Relationships

Create relationships&#x20;

Create a relationship between the existing nodes&#x20;

Create a relationship with labels and properties

```
CREATE (node1)-[:RelationshipType]->(node2)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gchandra.gitbook.io/big-data-and-tools-with-nosql/nosql/neo4j/neo4j-components.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
