Neo4j databases and graphs

This section describes databases and graphs in Neo4j.

Cypher queries are executed against a Neo4j database, but normally apply to specific graphs. It is important to understand the meaning of these terms and exactly when a graph is not a database.

DBMS

A Neo4j Database Management System is capable of containing and managing multiple graphs contained in databases. Client applications will connect to the DBMS and open sessions against it. A client session provides access to any graph in the DBMS.

Graph

This is a data model within a database. Normally there is only one graph within each database, and many administrative commands that refer to a specific graph do so using the database name.

Cypher queries executed in a session may declare which graph they apply to, or use a default, given by the session.

In Neo4j Fabric it is possible to refer to multiple graphs within the same query.

Database

A database is a storage and retrieval mechanism for collecting data in a defined space on disk and in memory.

Most of the time Cypher queries are reading or updating queries, which are run against a graph. There are also administrative commands that apply to a database, or to the entire DBMS. Administrative commands cannot be run in a session connected to a normal user database, but instead need to be run within a session connected to the system database.

1. The system database and the default database

All Neo4j servers contain a built-in database called system, which behaves differently than all other databases. The system database stores system data and you can not perform graph queries against it.

A fresh installation of Neo4j includes two databases:

  • system - the system database described above, containing meta-data on the DBMS and security configuration.

  • neo4j - the default database, named using the config option dbms.default_database=neo4j.

For more information about the system database, see the sections on Database management and Access Control.

2. Different editions of Neo4j

Neo4j has two editions, a commercial Enterprise Edition with additional performance and administrative features, and an open-source Community Edition. Cypher works almost identically between the two editions, and as such most of this manual will not differentiate between them. In the few cases where there is a difference in Cypher language support or behaviour between editions, these are highlighted as described below in Limited Support Features.

However it is worth listing up-front the key areas that are not supported in the open-source edition:

Feature Enterprise Community

Multi-database

Any number of user databases

Only system and one user database

Role-based security

User, Role and Privilege management for flexible access control and sub-graph access control.

Multi-user management. All users have full access rights.

Constraints

Existence constraints and multi-property NODE KEY constraints.

Only single property uniqueness constraints

3. Limited Support Features

Some elements of Cypher do not work in all deployments of Neo4j, and we use specific markers to highlight these cases:

Marker Description Example

deprecated

This feature is deprecated and will be removed in a future version

DROP INDEX ON :Label(property)

enterprise-only

This feature only works in the enterprise edition of Neo4j

CREATE DATABASE foo

fabric

This feature only works in a fabric deployment of Neo4j.

USE fabric.graph(0)