CosmosDB API selection: does it dictate how the data is stored, or only how we communicate with the instance?

≯℡__Kan透↙ 提交于 2020-01-16 11:32:19

问题


When creating a CosmosDB instance, we can choose the API that we will use to communicate with the instance (e.g. SQL, MongoDB, Cassandra, etc.)

What is not clear to me is - does this selection dictates how the data is stored, or only the way we communicate with the instance? For example, if we choose MongoDB, does it mean that CosmosDB will store data in a MongoDB fashion?


回答1:


The choice of API does not change how the data is stored. Cosmos DB always stores data using something called atom-record-sequence (ARS) which is essentially a set of primitive types, structs and arrays. The database engine translates the native ARS format into the data structures used by the various APIs (i.e. json documents, table rows, etc.)

So the answer to your question is that the choice of API only impacts how you communicate with the databases for that Cosmos DB account.

As David Makogon points out in his comment on another answer, while the way the data is stored is the same regardless of the API used, the content of the data will be different because each API requires it's own metadata so that the underlying data can be projected into the format expected by each API.

Here is a good technical overview of how Cosmos works under the hood.

https://azure.microsoft.com/en-us/blog/a-technical-overview-of-azure-cosmos-db/




回答2:


Data is always stored in the same fashion (as a bunch of json documents), only the way you interact with the data changes

https://docs.microsoft.com/en-us/azure/cosmos-db/introduction#develop-applications-on-cosmos-db-using-popular-open-source-software-oss-apis



来源:https://stackoverflow.com/questions/59471185/cosmosdb-api-selection-does-it-dictate-how-the-data-is-stored-or-only-how-we-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!