Neo 4j:
Neo4j is the world's leading open source Graph Database which is developed using Java
technology. It is highly scalable and schema free (NoSQL).
What is a Graph Database?
A graph is a pictorial representation of a set of objects where some pairs of objects are
connected by links. It is composed of two elements - nodes (vertices) and relationships
(edges).
Graph database is a database used to model the data in the form of graph. In here, the nodes
of a graph depict the entities while the relationships depict the association of these nodes
Popular Graph Databases
Neo4j is a popular Graph Database. Other Graph Databases are Oracle NoSQL Database,
OrientDB, HypherGraphDB, GraphBase, InfiniteGraph, and AllegroGraph.
Why Graph Databases?
Nowadays, most of the data exists in the form of the relationship between different objects
and more often, the relationship between the data is more valuable than the data itself.
Relational databases store highly structured data which have several records storing the same
type of data so they can be used to store structured data and, they do not store the
relationships between the data.
RDBMS Vs Graph Database
Following is the table which compares Relational databases and Graph databases.
[Link] RDBMS Graph Database
1 Tables Graphs
2 Rows Nodes
3 Columns and Data Properties and its values
4 Constraints Relationships
5 Joins Traversal
Advantages of Neo4j
Flexible data model − Neo4j provides a flexible simple and yet powerful data model,
which can be easily changed according to the applications and industries.
Real-time insights − Neo4j provides results based on real-time data.
High availability − Neo4j is highly available for large enterprise real-time
applications with transactional guarantees.
Connected and semi structures data − Using Neo4j, you can easily represent
connected and semi-structured data.
Easy retrieval − Using Neo4j, you can not only represent but also easily retrieve
(traverse/navigate) connected data faster when compared to other databases.
Cypher query language − Neo4j provides a declarative query language to represent
the graph visually, using an ascii-art syntax. The commands of this language are in
human readable format and very easy to learn.
No joins − Using Neo4j, it does NOT require complex joins to retrieve
connected/related data as it is very easy to retrieve its adjacent node or relationship
details without joins or indexes.
Features of Neo4j:
Data model (flexible schema) − Neo4j follows a data model named native property
graph model. Here, the graph contains nodes (entities) and these nodes are connected with
each other (depicted by relationships). Nodes and relationships store data in key-value
pairs known as properties.
In Neo4j, there is no need to follow a fixed schema. You can add or remove properties as
per requirement. It also provides schema constraints.
ACID properties − Neo4j supports full ACID (Atomicity, Consistency, Isolation, and
Durability) rules.
Scalability and reliability − You can scale the database by increasing the number of
reads/writes, and the volume without effecting the query processing speed and data
integrity. Neo4j also provides support for replication for data safety and reliability.
Cypher Query Language − Neo4j provides a powerful declarative query language
known as Cypher. It uses ASCII-art for depicting graphs. Cypher is easy to learn and can
be used to create and retrieve relations between data without using the complex queries
like Joins.
Built-in web application − Neo4j provides a built-in Neo4j Browser web application.
Using this, you can create and query your graph data.
Drivers − Neo4j can work with −
REST API to work with programming languages such as Java, Spring, Scala etc.
Java Script to work with UI MVC frameworks such as Node JS.
It supports two kinds of Java API: Cypher API and Native Java API to develop Java
applications. In addition to these, you can also work with other databases such as
MongoDB, Cassandra, etc.
Indexing − Neo4j supports Indexes by using Apache Lucence.
Neo4j Data Model:
Neo4j Graph Database follows the Property Graph Model to store and manage its data.
Key features of Property Graph Model:
The model represents data in Nodes, Relationships and Properties
Properties are key-value pairs
Nodes are represented using circle and Relationships are represented using arrow keys
Relationships have directions: Unidirectional and Bidirectional
Each Relationship contains "Start Node" or "From Node" and "To Node" or "End
Node"
Both Nodes and Relationships contain properties
Relationships connects nodes
In Property Graph Data Model, relationships should be directional. If we try to create
relationships without direction, then it will throw an error message.
In Neo4j too, relationships should be directional. If we try to create relationships
without direction, then Neo4j will throw an error message saying that "Relationships
should be directional".
Neo4j Graph Database stores all of its data in Nodes and Relationships. We neither
need any additional RRBMS Database nor any SQL database to store Neo4j database
data. It stores its data in terms of Graphs in its native format.
Neo4j uses Native GPE (Graph Processing Engine) to work with its Native graph
storage format.
The main building blocks of Graph DB Data Model are
Nodes
Relationships
Properties
simple example of a Property Graph.
Here, we have represented Nodes using Circles. Relationships are represented using Arrows.
Relationships are directional. We can represent Node's data in terms of Properties (key-value
pairs). In this example, we have represented each Node's Id property within the Node's Circle.