Archive for the ‘Neo4j’ Category

Neo4j – Introduction

Posted: November 27, 2016 in Database, Neo4j
Tags: , , ,

What is Neo4j?

  • Neo4J is an open-source, schema-free, NoSQL, popular graph database which saves data structure in graph rather than in tables.
  • Neo4J is written and implemented in Java language.
  • Neo4J is written on the top of JVM.
  • It can do memory caching for graphs and provides compact storage, resulting in efficient scale-up.
  • It provides continuous time traversals for relationship in the graph both in breadth and depth due to double linking on the storage level between nodes and relationships.
  • Relationship in Neo4j is fast and makes it possible to materialize and use new relationships later on to “shortcut” and speed up the domain data when new requirement arises.
  • Neo4J stores graph data in a number of different store files, and each store file contains the data for a specific part of the graph for example relationships, nodes, properties etc


When to use Neo4J?

  1. Highly connected data ? Social Network
  2. Recommendation- ( e-commerce)
  3. Path Finding
  4. Data First Schema (bottom-up)
  5. Schema Evolution
  6. A*(Least Cost Path)

Comparing Neo4j and RDBMS

RDBMS Graph Database
Tables Graphs
Rows Nodes
Columns and Data Properties and its Values
Constraints Relationships
Joins Traversal

Nodes: They are entities equivalent to rows in table.
Relationship: It connects entities and structure domain.
Properties: It contains meta-data and attributes.
Labels: It groups nodes by role.

Comparing Neo4j and MySQL

Neo4J contains vertices and edges. Each vertex or node represent a key value or attribute. In MySQL, attributes are appended in plain table format.
In Neo4J, it is possible to store dynamic content like images, videos, audio etc. In relational databases, such as MySQL, it is difficult to store videos, audios and images.
It provides the capability of deep search into the database without affecting the performance along with efficient timing. It takes longer time for database search and also inconvenient compared to Neo4J.
In Neo4j, two or more objects can be related by making relationship between them. It lacks relationship and very difficult to use them for connected graphs and data.

Cache in Neo4j

Neo4j utilizes two different types of cache.
A file buffer cache and an object cache.
The file buffer cache caches the storage file data in the same format as it is stored on the durable storage media.
The object cache caches the nodes, relationships and properties in a format that is optimized for high traversal speeds and transactional mutation.

(More about Neo4j Caches and how to configure them will be covered in a separate article)

How to query Neo4j Database?

  • Cypher Query Language (CQL) is used by Neo4J.
  • Cypher is a declarative, SQL-inspired language for describing patterns in graphs visually using an ascii-art syntax.
  • It allows us to state what we want to select, insert, update or delete from our graph data without requiring us to describe exactly how to do it.

(To fully utilize the power of our graph database we want to express more complex patterns between our nodes. More about relationships and CQL will be covered in a separate article)