What is Neo4j? What are the benefits of Neo4j?

What is Neo4j? What are the benefits of Neo4j?

Neo4j is a graph database that has the capability to store and process large and relational data, does not require much difficulty in usage (even has a query language they call similar to sql called cypher ) and is ranked high in the DB-Engines ranking. According to their own words, we can define it as "The Fastest Path to Graph" . After finding the answer to the question What is Neo4j?, there are a few important terms we use while determining our structure, let's go through them.

What are Nodes? What are Labels?

Before using the Neo4j database, let's answer the questions what are nodes and what are labels .

Nodes

Each record is a node for us. These are our main records, and we can add features we call "Properties" such as id, name, title into these records. While using these, we can utilize the label feature to keep everything more organized.

Labels

Labels, or tags, are the names we give to these groups of nodes. The information such as 'Person', 'Company', etc. that we can specify as a group will be tags representing separate nodes.

While creating a node without a label

Create (n)

we can create a node with a label as

Create (n:Person)

We can also create this node particularly together

Create (n:Person {id:1, companies: [1,2,3], name: 'Burak'})

Thus, I created a few bulk records below as I will use Person and Company information in our example.

Create (q:Person {id:1, companies: |1,2,3|, name: 'Burak'}),
(w:Person {id:2, companies: [1], name: 'Uzay'}),
(e:Person {id:3, companies: [2], name: 'Yaprak'}),
(r:Person {id:4, companies: [3], name: 'Ali'}),
(t:Person {id:5, companies: [2,4], name: 'Veli'}),
(y:Company {id:1, name: 'X Company'}),
(u:Company {id:2, name: 'Y Company'}),
(o:Company {id:3, name: 'Z Company'}),
(p:Company {id:4, name: 'Q Company'})
Here, 5 records belonging to the Person label and 4 nodes in the Company label were created.


Our Person nodes were formed as follows;

Our Company nodes are as follows;


A node can have multiple labels or none at all. These do not hold any extra features as they only perform grouping actions. All properties can be held by node information.

Relationships

Neo4j 's most important feature is the relationships we call relationships. Depending on the query we write here, it can yield amazing results quickly while establishing relationships between levels 1-1 as well as levels 2, 3, and above.

Going from the example above, it is seen that each person is connected with one or more companies. Here, we can create the relationship we will call PersonCompany by combining it with the where clause in sql logic, as follows.

Match (a:Person), (b:Company)
where (b.id IN a.companies)
create (a) - [r:PersonCompany {name:a.name+'<->'+b.name}] -> (b)
return type(r), a,b
After creating our relationships, our final view in Neo4j looks like this;



At a basic level, we have made an introduction to what a Neo4j database is and what gains it provides during use. It is up to you to develop and use these according to your needs.

Good luck! 

Looking for authors and journalists!

Looking for authors and journalists!

If you are a journalist, who has desire to dig deep in topics related to businesses and sectors, we want to work with you!

Burak Kaşıkcı

PlusClouds Enthusiast
Sales

Product information

#There is no text provided for translation. Please provide the text you would like to be translated into English.
Auto Quill
AutoQuill writes and posts affiliate marketing content for you.

Easiest Money You Will Ever Make

With the AutoQuill tool that PlusClouds has started to offer to its affiliate partners, content creators will be able to sell with a single click. Let us show you how you can get your share of this revolution.