What is a graph database

A Neo4j graph database stores data as nodes, relationships, and properties instead of in tables or documents. This means you can organize your data in a similar way as when sketching ideas on a whiteboard.

And since graph databases are not restricted to a pre-defined model, you can take more flexible approaches and strategies when working with them.

sample cypher
Figure 1. A visual way of matching patterns and relationships using Cypher

How it works

Graph databases are structured through nodes and relationships.

Nodes are entities in the graph which can:

Relationships provide named connections between two nodes (e.g., Person - LOVES - Person) and they:

  • Must always have a start node, an end node, and exactly one type.

  • Must have a direction.

  • Can have properties, like nodes.

  • Nodes can have multiple relationships of various types without sacrificing performance.

In summary, nodes and relationships are an efficient and flexible way to store data since they allow you to:

  • Create traversals in big graphs for both depth and breadth.

  • Scale-up your database to billions of nodes.

  • Design flexible property graph data models that can adapt over time.

Why use a graph database

Projects often deal with large amounts of complex data and graph databases can be a powerful tool.

There are other ways to store data as objects and connections, such as relational databases, for example. However, relational databases use computing-wise expensive JOIN operations or cross-looks, which are often tied to a rigid data model.

Graph databases do not use JOINs. Rather, relationships are stored natively alongside the data elements (nodes) in a more flexible format, which allows the optimization of data traversing and millions of connections to be accessed per second.

Moreover, many daily challenges and tasks can be viewed from a graph perspective as it allows you to:

  • Navigate deep hierarchies.

  • Find hidden connections between distant items.

  • Discover inter-relationships between items.

How to use

Whether it’s a social or a road network, all networks can be structured as an interconnected graph of relationships. Many times, a project’s questions and challenges revolve around the relationship between elements, not the elements themselves (e.g. how to get from A to B, instead of what A is and what B is). For this reason, graphs can be applied to many areas of society and to a wide variety of projects.

Neo4j is frequently used today by startups, educational institutions, and large enterprises in a variety of sectors including financial services, government, energy, technology, retail, and manufacturing. Graphs have been successful in helping them on the development of innovative new technology, business management, insight and revenue regenration, as well as overall improvements in efficiency.

You can find more information about use cases on Neo4j’s main website.

Keep learning

If you want to get a better and deeper understanding of graph databases, you can read more about Graph database concepts, or enroll to the GraphAcademy course on Neo4j Fundamentals.

Glossary

label

Marks a node as a member of a named and indexed subset. A node may be assigned zero or more labels.

labels

A label marks a node as a member of a named and indexed subset. A node may be assigned zero or more labels.

node

A node represents an entity or discrete object in your graph data model. Nodes can be connected by relationships, hold data in properties, and are classified by labels.

nodes

A node represents an entity or discrete object in your graph data model. Nodes can be connected by relationships, hold data in properties, and are classified by labels.

relationship

A relationship represents a connection between nodes in your graph data model. Relationships connect a source node to a target node, hold data in properties, and are classified by type.

relationships

A relationship represents a connection between nodes in your graph data model. Relationships connect a source node to a target node, hold data in properties, and are classified by type.

property

Properties are key-value pairs that are used for storing data on nodes and relationships.

properties

Properties are key-value pairs that are used for storing data on nodes and relationships.

cluster

A Neo4j DBMS that spans multiple servers working together to increase fault tolerance and/or read scalability. Databases on a cluster may be configured to replicate across servers in the cluster thus achieving read scalability or high availability.

clusters

A Neo4j DBMS that spans multiple servers working together to increase fault tolerance and/or read scalability. Databases on a cluster may be configured to replicate across servers in the cluster thus achieving read scalability or high availability.

graph

A logical representation of a set of nodes where some pairs are connected by relationships.

graphs

A logical representation of a set of nodes where some pairs are connected by relationships.

schema

The prescribed property existence and datatypes for nodes and relationships.

schemas

The prescribed property existence and datatypes for nodes and relationships.

[[database schema]]database schema

The prescribed property existence and datatypes for nodes and relationships.

indexes

Data structure that improves read performance of a database. Read more about supported categories of indexes.

indexed

Data structure that improves read performance of a database. Read more about supported categories of indexes.

constraints

Constraints are sets of data modeling rules that ensure the data is consistent and reliable. See what constraints are available in Cypher.