Introduction

Introduction to managing multiple active databases with Neo4j.

1. Concepts

With Neo4j 4.3 you can create and use more than one active database at the same time.

DBMS

Neo4j is a Database Management System, or DBMS, capable of managing multiple databases. The DBMS can manage a standalone server, or a group of servers in a Causal Cluster.

Instance

A Neo4j instance is a Java process that is running the Neo4j server code.

Transaction domain

A transaction domain is a collection of graphs that can be updated within the context of a single transaction.

Execution context

An execution context is a runtime environment for the execution of a request. In practical terms, a request may be a query, a transaction, or an internal function or procedure.

Database

A database is an administrative partition of a DBMS. In practical terms, it is a physical structure of files organized within a directory or folder, that has the same name of the database. In logical terms, a database is a container for one or more graphs.

A database defines a transaction domain and an execution context. This means that a transaction cannot span across multiple databases. Similarly, a procedure is called within a database, although its logic may access data that is stored in other databases.

A default installation of Neo4j 4.3 contains two databases:

  • system - the system database, containing metadata on the DBMS and security configuration.

  • neo4j - the default database, a single database for user data. This has a default name of neo4j. A different name can be configured before starting Neo4j for the first time.

Graph

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

In Neo4j Fabric, it is possible to refer to multiple graphs within the same transaction and Cypher query.

The following image illustrates a default installation, including the system database and a single database named neo4j for user data:

manage dbs community
Figure 1. A default Neo4j installation.
Editions

The edition of Neo4j determines the number of possible databases:

  • Installations of Community Edition can have exactly one user database.

  • Installations of Enterprise Edition can have any number of user databases.

All installations include the system database.

2. The system database

All installations include a built-in database named system, which contains meta-data and security configuration.

The system database behaves differently than all other databases. In particular, when connected to this database you can only perform a specific set of administrative functions, as described in detail in Cypher Manual → Administration.

Most of the available administrative commands are restricted to users with specific administrative privileges. An example of configuring security privileges is described in Fine-grained access control. Security administration is described in detail in Cypher Manual → Security of administration .

The following image illustrates an installation of Neo4j with multiple active databases, named marketing, sales, and hr:

manage dbs enterprise
Figure 2. A multiple database Neo4j installation.

3. The default and home database

If a user connects to Neo4j without specifying a database, they will be connected to a home database. When choosing a home database the server will first use the home database configured for that user. If the connecting user does not have a home database configured, the server will use the default database, which every Neo4j instance has.

The default database is configurable. For details, see configuration parameters.

The following image illustrates an installation of Neo4j containing the three databases for user data, named marketing, sales and hr, and the system database. The default database is sales:

manage dbs default
Figure 3. A multiple database Neo4j installation, with a default database.

4. Per-user home databases

Per-user home databases are controlled via the Cypher administration commands.

To set a home database for a user, this user must exist as a record in Neo4j. Therefore, for deployments using auth providers other than native, you create a native user with a matching username and then set a home database for that user. For more information on creating native users and configuring a home database for a user, see Cypher Manual → User Management.