API version: 0.3.0

---

# Databases

Ember Nexus stores the data of an element in several databases, each one doing what it is best at. They are either
primary or secondary:

- A **primary database** holds the original copy of a piece of data, nothing else generates or supplies it.
- A **secondary database** holds data which is derived from the primary databases, and which can be rebuilt from them.

| Database                                               | Kind      | Holds                                                                |
| ------------------------------------------------------ | --------- | -------------------------------------------------------------------- |
| [Neo4j](/reference/databases/neo4j.md)                 | primary   | The graph: nodes, relations, ownership and access, scalar properties |
| [MongoDB](/reference/databases/mongodb.md)             | primary   | Objects, lists, vectors, geo values and long strings                 |
| [Elasticsearch](/reference/databases/elasticsearch.md) | secondary | A copy of the properties for the search                              |
| [S3](/reference/databases/s3.md)                       | primary   | The files of elements                                                |

Every property is stored in exactly one primary database. Which one is decided by the
[placement](/reference/schemas/placement.md) of the schema, and every [type](/reference/schemas/types.md) lists the databases
which can store it.

## Why Elasticsearch is secondary

Elasticsearch is great at searching, but not a good place for the only copy of data:

- It is not real-time: written documents become searchable after the next refresh, about one second later. Reading an
  element right after a write has to return the written data, which the primary databases guarantee.
- It can be rebuilt from the primary databases at any time, e.g. after a change of a mapping, which would be
  impossible if it held data on its own.
- [Backups](/command/backup-create.md) only read the primary databases, and loading one rebuilds the search copy.

The setting `search` of a property therefore only decides whether the property is copied to Elasticsearch, never where
it is stored.

## Why Neo4j is always needed

Access to every element is decided by the relations of the graph, see the [access model](/reference/access-model.md). A
graph database is therefore required for every request, even if all properties of a type are stored in MongoDB.

## Limits

Most limits which you can run into do not come from the API, but from the databases. Every database page lists the
limits which matter in practice, e.g. the maximum size of a MongoDB document or the number of fields of an
Elasticsearch index. The limits which the API enforces itself are listed in [limits](/reference/limits.md).

---

Home: [Ember Nexus API docs](/index.md)

Full site map: [llms.txt](/llms.txt)

Previous: [Raw Neo4j indices](/reference/indices/raw-indices/neo4j.md)

Next: [Neo4j](/reference/databases/neo4j.md)
