Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean that Azure Cosmos DB is multi-model?

Looking at the new Azure cosmos database, I'm a bit confused about the multi-model nature of it. Specifically, does it mean:

a) That the same underlying database/store can be queried multiple ways concurrently so that I can use both gremlin graph queries and mongodb api against the same collections.

  • or -

b) Does it mean that you can choose a different model (graph, key value, column, document) at the time of provisioning your Cosmos DB and that is how the data will be stored from then on.

The brochure makes it sound like a), but using the Azure dashboard to create a cosmos instance it makes it seem like b) since you have to choose a model type at creation.

Additionally, the literature makes reference to columnar data, but I don't see the option for it at create time.

like image 543
MonkeyBonkey Avatar asked Jun 01 '17 10:06

MonkeyBonkey


People also ask

What is a multi-model database management system?

A multi-model database is a management system that combines multiple database types with a single backend. Most database management systems support only a single database model. On the other hand, multi-model databases store, query, and index data from different models.

What type of service model is the Azure Cosmos DB service?

Azure Cosmos DB is a fully managed, serverless NoSQL database for high-performance applications of any size or scale.

Can I use multiple APIs to access the data in Cosmos DB?

Can I use multiple APIs to access my data? Azure Cosmos DB is Microsoft's globally distributed, multi-model database service. Where multi-model means Azure Cosmos DB supports multiple APIs and multiple data models, different APIs use different data formats for storage and wire protocol.

What type of database is Cosmos DB?

Cosmos DB is a multi-model NoSql database. Currently it can handle three types of non-relational data: Document databases.


2 Answers

Cosmos DB is a single NoSQL data engine, an evolution of Document DB. When you create a container ("database instance") you choose the most relevant API for your use case which optimises the way you interact with the underling data store and how the data is persisted in to that store.

So, depending on the API chosen, it projects the desired model (graph, column, key value or document) on to the underlying store.

You can only use one API against a container, multiple are not possible due to the way the data is stored and retrieved. The API dictates the storage model - graph, key value, column etc, but they all map back on to the same technology under the hood.

Thanks to @Jesse Carter's comment below it appears you are however able to mix and match the graph and DocumentSQL APIs.

From the docs:

Multi-model, multi-API support

Azure Cosmos DB natively supports multiple data models including documents, key-value, graph, and column-family. The core content-model of Cosmos DB’s database engine is based on atom-record-sequence (ARS). Atoms consist of a small set of primitive types like string, bool, and number. Records are structs composed of these types. Sequences are arrays consisting of atoms, records, or sequences. The database engine can efficiently translate and project different data models onto the ARS-based data model. The core data model of Cosmos DB is natively accessible from dynamically typed programming languages and can be exposed as-is as JSON.

The service also supports popular database APIs for data access and querying. Cosmos DB’s database engine currently supports DocumentDB SQL, MongoDB, Azure Tables (preview), and Gremlin (preview). You can continue to build applications using popular OSS APIs and get all the benefits of a battle-tested and fully managed, globally distributed database service.

like image 180
Murray Foxcroft Avatar answered Oct 17 '22 06:10

Murray Foxcroft


Cosmos DB at its heart is a geographically distributed database with its own Atom-Record-Sequence storage engine and index. On top of that infrastructure we are able to implement many different kinds of stores, from SQL like stores using our SQL API, to Mongo, to Cassandra, to Gremlin, to an implementation of Azure Table storage and so on.

Each of the different store types have their own data types (e.g. ways of encoding numbers, dates, etc.) and are encoded in our storage and index layer in their own way. Over time we expect most of those data types to be natively supported by our SQL API. But for now each of our data base types uses its own encoding conventions. When creating an account in Cosmos DB (this is a unit of organization, users can have many accounts) the "type" of Database is specified on the account. So one can have a Table API account or a Mongo account or what have you.

In some cases it is possible to access an account with Data Type X using API Y. For example, one can use SQL API to talk to tables in a Table API account. But outside of graph, that is usually not a great idea. Right now we encode information for each API in a special format and the different data types don't speak each other's formats. So if one were to write to a Table API using SQL API the end result will most likely be corrupt data.

The exception is graph which we work hard to make sure work reasonably well with all database types and we'll have more to say on that in the future.

So if you do want to play around with multi API access we strongly encourage you to only do so in "read only" mode when not using the "native" API for the given account. In other words, by all means play around with the SQL API reading from a Table API, just please don't write to a Table API account suing a SQL API client.

like image 19
Yaron Y. Goland Avatar answered Oct 17 '22 06:10

Yaron Y. Goland