What is Azure Cosmos DB?
Azure Cosmos DB is a fully managed Azure cloud-only distributed NoSQL database for high-performance applications of any size and scale.
In this article we will explain what are the main features of CosmosDB as a service, and the main features of a CosmosDB database by comparing it to relational databases.
Key features of Azure Cosmos DB
The main features of Azure Cosmos DB are as follows:
-Higher read and write speed than relational databases.
-Supports different NoSQL systems such as MongoDB, Cassandra and Gremlin, apart from the most used native Core (SQL) API. Each of them through its SDK
-Guaranteed 99.999% availability, backup support, point-in-time restore, security, and real-time analytics with no performance loss using Azure Synapse Link for Azure Cosmos DB
-Offers high performance thanks to instant and automatic vertical scaling with consumption-based costs.
-You pay only for what you consume, there are no minimum charges of any kind. With the possibility of calculating costs in advance.
CosmosDB databases
Unlike the relational database, CosmosDB databases (native Core API) are structured much more simply, since instead of tables they have containers and these, in turn, contain records (rows) that are stored in the form of JSON. That is, there is no concept of column, although by convention all collections must have an alphanumeric “id” property that acts as the primary key and a property must also be specified as the partition key.
Some of the characteristics of containers are that they have no referential integrity, do not support transactions between containers, and one container cannot access data from another container, since the maximum size of a record is 2MB.
The data model is different from the relational one, instead of having many tables related to each other, in NoSQL it is modeled more hierarchically. So in a single record there can be the equivalent of several tables of a relational database.
The concept of partitioning is similar to that of SQL Server, a property partitions and for each different value it has internally creates a division of the data, allowing individual scaling for each container. Currently, the ability to partition with more than one property is in Preview.
It supports stored procedures, user-defined functions and Trigger, which are programmed in JavaScript and can only access the data of the container in which they are.
As in a relational database, performance is not intrinsic to the database, it depends on the data model, indexes, and partition key.
Access to data from the CosmosDB itself is through its own SQL, much like the SQL of relational databases. From the .NET SDK it can be accessed through EF or the native API, either by doing SQL queries or by Linq which is the most conventional.
Data Explorer
The Data Explorer is the equivalent of SQL Server Manager Studio, it is a web environment in which you can perform basic tasks, maintenance of a database, such as creating databases, containers, indexes, etc. (period) and data management where you can make queries, registrations, cancellations and modifications of data.
Trial version
For those who do not have an Azure subscription, there is a CosmosDB emulator that can be installed on both Windows and Linux for local testing, including the database engine and Data Explorer for management.
Use cases
In Pasiona we have already used CosmosDB in several projects such as Camperxpress with excellent results, since it offers a very smooth learning curve and it is easy to train new colleagues who have no previous experience.
Azure Cosmos DB, Data Explorer, Databases, Native Core API
Go back