> For the complete documentation index, see [llms.txt](https://gchandra.gitbook.io/big-data-and-tools-with-nosql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gchandra.gitbook.io/big-data-and-tools-with-nosql/nosql/neo4j/neo4j-components.md).

# 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)
```
