Multiple Databases – New Feature in Version 1.4

Documentation, Releases Leave a comment

ArangoDB 1.4 provides support for multiple databases, a feature often requested by our users.

Motivation

In the old days, ArangoDB provided the option to create multiple collections, but all collections were created on the same level. As there was no hierarchy of collections, there was a chance of having a collection name clash when using one ArangoDB server for multiple applications.

For example, running multiple applications inside the same ArangoDB server did not work if all applications created their own users collections. Workarounds, such as prefixing collection names, were required to make older ArangoDB versions play nicely with multiple applications.

With ArangoDB 1.4, multiple databases are supported natively. Workarounds such as prefixing collection names with application names, can go away now.

How it works

With multiple databases, different applications can manage their data independently, using isolated databases each. Databases can be dropped entirely, without affecting collections of other applications.

For example, creating two independent databases that both have their own messages collection is just simple. First database (named myblog):

db._createDatabase("myblog");  // create the database
db._useDatabase("myblog");     // switch into new database
db._create("messages");        // create collection "messages"

We can do the same in another database (named mychat):

db._createDatabase("mychat");  // create the database
db._useDatabase("mychat");     // switch into new database
db._create("messages");        // create collection "messages"

Individual databases can be accessed via the HTTP API by putting the database name into URLs, e.g.

http://localhost:8529/_db/myblog/_api/document/messages/1234

This is the recommended mechanism, though for compatibility reasons ArangoDB also supports URLs that do not contain the database’s name. In case the database name is omitted, ArangoDB will fall back to the default _system database.

Access rights are also managed per database, allowing user-specific database access in a multi-user context.

More details on how to use the multiple databases feature can be found here.

About Jan Steemann

Jan is a member of ArangoDB's core development team. He is an expert in data modelling with nosql & relational databases and writing high performance web applications. For ArangoDB, he wrote much of AQL (ArangoDB's query language).