Introduction

An introduction to composite databases.

Overview

Composite databases allow queries that access multiple graphs at once. This is a function that enables:

  • Data Federation: the ability to access data available in distributed sources in the form of disjointed graphs.

  • Data Sharding: the ability to access data available in distributed sources in the form of a common graph partitioned on multiple databases.

Concepts

Composite databases don’t store any data on their own, but rather give access to the graphs found on other databases. These graphs are added to the composite database by means of database aliases.

A Neo4j DBMS can have multiple composite databases, and they can be created both in single-instance deployments, and in cluster deployments.

Composite databases are managed using administrative commands. They are created with the CREATE COMPOSITE DATABASE command.

Example 1. Creating a composite database
CREATE COMPOSITE DATABASE cineasts

Constituent graphs are added with the CREATE ALIAS administrative command, for example:

Example 2. Creating an alias on a composite database
CREATE ALIAS cineasts.latest
  FOR DATABASE movies2022

Aliases can also be created for databases on other DBMSs:

Example 3. Creating an alias for a remote database on a composite database
CREATE ALIAS cineasts.upcoming
  FOR DATABASE upcoming
  AT 'neo4j+s://other.dbms.com'
  USER $user
  PASSWORD $password

The SHOW DATABASE administrative command includes composite databases.

Their type is reported as "composite", and the constituents column lists the names of the aliases contained.

Example 4. Showing a composite database
SHOW DATABASE cineasts YIELD name, type, constituents
+---------------------------------------------------------------------+
| name       | type        | constituents                             |
+---------------------------------------------------------------------+
| "cineasts" | "composite" | ["cineasts.latest", "cineasts.upcoming"] |
+---------------------------------------------------------------------+

The SHOW ALIASES FOR DATABASE administrative command can be used to inspect aliases on composite databases in further detail.

Example 5. Showing composite database aliases
SHOW ALIASES FOR DATABASE
+----------------------------------------------------------------------------------------+
| name                | database     | location | url                        | user      |
+----------------------------------------------------------------------------------------+
| "cineasts.latest"   | "movies2022" | "local"  | NULL                       | NULL      |
| "cineasts.upcoming" | "upcoming"   | "remote" | "neo4j+s://other.dbms.com" | "cineast" |
+----------------------------------------------------------------------------------------+

For a full description of the administrative commands for managing composite databases, see Cypher Manual → Database management.