Azure Cosmos DB APIs – Nonrelational Databases in Azure
Azure Cosmos DB APIs
Azure Cosmos DB offers multiple database APIs to create different types of NoSQL databases, including the following options:
- Table API for key-value stores
- Core (SQL) API for document databases
- API for MongoDB for document databases
- Cassandra API for columnar databases
- Gremlin API for graph databases
Users are asked to select an API when creating an Azure Cosmos DB account for the first time. Choosing the most appropriate API depends entirely on the solution(s) that instance of Azure Cosmos DB will be supporting. The following sections will discuss each API and when to use them.
Table API
The Azure Cosmos DB Table API is a key-value store that is based on Azure Table storage. The differences are primarily focused on features that are inherent to the Azure Cosmos DB service such as higher performance and availability, global distribution, automatic secondary indexes, and more options for configuring throughput. However, it is important to know the core components of Azure Table storage to understand how to implement a key-value store with the Azure Cosmos DB Table API.
Azure Table storage is a key-value store that stores nonrelational, structured data. Containers in Azure Table storage are represented as tables and can be created in an Azure storage account. Data is stored in tables as a collection of entities, like rows in a relational database. Individual data fields in entities are represented as properties. Properties are like columns in a relational database.
While the terminology may present Azure Table storage as a relational data store, it is far from it. Tables do not enforce a schema on entities, allowing entities to have different sets of properties. However, there are some entity conditions that must be adhered to. First, each entity must include a set of system properties that specify a partition key, a row key, and a time stamp. Second, there is also a 255-property limit that includes the three previously mentioned system properties.