Search Tutorials

Neo4j Tutorials - Understanding the need for Graph Database | JavaInUse

Need of Graph Database

What is Graph Database

A graph database, also called a graph-oriented database, is a type of NoSQL database that uses graph theory to store, map and query relationships. A graph database is essentially a collection of nodes and edges.

Neo4j - Table Of Contents

Need for Neo4j Install Neo4j Neo4j Cypher


This tutorial is explained in the below Youtube Video.

Why do we need it?

Consider the following example-
Here we have normalized tables having foreign key relationships. Here if we want to find data like suppose which product the customer bought. But suppose we want data like which organization in city1 ordered the item product a. This can obviously be done in Relational database, but consider the number of joints. They involve disk io calls and are expensive. As we go on performing queries deeper and deeper, relational database queries might become more and more complex and expensive. The true value of the graph approach becomes evident when one performs searches that are more than one level deep.

How Neo4j helps?

Instead of using foreign key constraints, graph databases directly store the relationships between records. So instead of an employee name being found by looking up its user's key in the id column, the user record has a pointer directly to the name record. That is, having selected a user, the pointer can be followed directly to the name records, there is no need to search the person table to find the matching records. This can eliminate the costly join operations.
So here we can see relationship between citizen1. If any data is required a hop is made directly to the required data. So no indexing is required. This is known as index-free adjacency Graph database should be used for scenarios where a lot of Navigation is required. For example a Social networking site. If the level of chaining is not deep then relational databases would be more suitable.