Azure Cosmos DB: Relational and NoSQL Database

  1. Home
  2. /
  3. Azure-Cosmos-DB-Developer-Specialty
  4. /
  5. Azure Cosmos DB: Relational and NoSQL Database
Azure Cosmos DB

Azure Cosmos DB is a fully managed, globally distributed database service that supports multiple data models including key-value, document, graph, and column-family. It provides horizontal scalability, global distribution, multi-master replication, automatic indexing and query, tunable consistency levels, and guaranteed low latency at the 99th percentile.

Key benefits of Azure Cosmos DB:

  • Multiple data models: Supports document, key-value, wide-column, and graph data, making it a versatile database for modern applications.
  • Global distribution: Replicate data across any number of Azure regions for high availability and low latency worldwide access.
  • Automatic indexing: Index all data by default without requiring any schema or indexes to be defined upfront.
  • Tunable consistency: Choose from 5 well-defined consistency models to balance availability, latency, throughput and consistency based on your application needs.
  • Guaranteed high performance: Industry-leading <50ms latency at the 99th percentile backed by comprehensive SLAs.
  • Serverless and elastic: Auto-scale throughput from thousands to over a million requests per second without downtime.

Use cases:

  • Gaming: Store player profiles, gaming statistics, locations, friends graph in a fast NoSQL store.
  • Retail: Maintain product catalogs with related hierarchical data and recommendations graph.
  • IoT: Ingest data from millions of sensors and devices globally into a fast time-series store.
  • Web and mobile applications: Store user profiles, activities, posts, comments with relationships.

By using Azure Cosmos DB as a versatile, globally distributed database, developers can build highly responsive and always available applications to meet the needs of today’s customers. Its automatic indexing and querying makes it easier to focus on business logic rather than database management.

What is a Database?

A database is a structured collection of data stored in a computer system. It is designed to efficiently store, retrieve, query, update and manage data.

Some key things to know about databases:

  • Databases organize data into tables, rows and columns, with relationships defined between the different tables. This allows efficient storage and retrieval of information.
  • Databases use special software called Database Management Systems (DBMS) to create, access, secure and manage the data. Examples of DBMS include MySQL, Oracle, Microsoft SQL Server, etc.
  • Databases enable users and applications to perform CRUD operations: Create, Read, Update and Delete data as needed.
  • Databases provide safe multi-user access to data via user accounts, roles, permissions, and security policies. This ensures integrity of data.
  • Databases allow administrators to set up rules, constraints, triggers and other constructs to enforce data validation, integrity and quality.

In summary, a database is an essential component of most software applications and IT systems today. It enables efficient storage and management of data at scale across the organization. Choosing the right database platform is crucial based on application data requirements and usage patterns.

What is Azure Cosmos DB?

Azure Cosmos DB is a globally distributed, multi-model database service provided by Microsoft Azure. Here are some of its key capabilities:

  • It supports multiple data models including document, key-value, wide-column and graph databases all accessed via common APIs.
  • It provides turnkey global distribution, elastic scaling of throughput and storage across any number of Azure regions. This enables low latency access to data from anywhere.
  • It guarantees single-digit millisecond response times, 99.999% high availability, and automatic and instant scalability, making it ideal for web, mobile, gaming and IoT applications.
  • It offers comprehensive service level agreements (SLAs) related to throughput, latency, availability and consistency.
  • It secures data via encryption, backup/restore, access control and other enterprise-grade features.

In summary, Azure Cosmos DB is a versatile, high-performance, globally distributed database platform for modern applications. Its unique multi-model and multi-API capabilities provide flexibility to use the right data model for your application’s needs.

Relational Database

Azure Cosmos DB provides a fully managed NoSQL database that supports multiple data models, including document, key-value, wide-column, and graph. However, it does not natively support relational data models like a SQL database would.

Here are some key points on using Azure Cosmos DB as a relational database:

  • Azure Cosmos DB is not a relational database. It uses JSON documents to store data rather than tables with rigid schemas. This provides flexibility but lacks some relational features.
  • You can model relational data in Azure Cosmos DB using techniques like embedding related data in a single JSON document. However, joins and complex relational queries are not supported.
  • If you need full relational capabilities like ACID transactions, complex querying, and integrity constraints, use an Azure SQL database instead. Azure Cosmos DB targets modern applications that need flexibility and scalability over strict relational needs.
  • You can use Azure Cosmos DB’s SQL API to write SQL-like queries against your JSON data. But the query language and capabilities are limited compared to T-SQL on Azure SQL databases.
  • For relational workloads, consider using Azure SQL Database or Azure SQL Managed Instance. Or host your own relational database like SQL Server on an Azure VM.

NoSQL Database

Azure Cosmos DB is a fully managed, globally distributed NoSQL database service provided by Microsoft Azure. It offers turnkey global distribution, elastic scaling, single-digit millisecond response times, and automatic indexing over data schemas.

Some key features of Azure Cosmos DB as a NoSQL database are:

Schema-agnostic data model

  • Stores data in JSON format allowing for flexible schemas
  • No need to define or maintain schemas upfront
  • Easily evolve data as needed

Horizontal scaling

  • Scales storage and throughput elastically on demand
  • Supports scaling to massive volumes of data across multiple regions

Low latency and high availability

  • Guaranteed single-digit millisecond latencies at 99th percentile
  • Offers multi-master replication for high availability
  • 99.999% read/write availability even in the event of regional outrages

Fully managed service

  • Automated scaling, patching, backups, and updates
  • Serverless model with no infrastructure to manage

Multiple data models

  • Supports document, key-value, wide-column, and graph data models
  • Query all models through SQL API

Global distribution

  • Natively replicates data across any number of Azure regions
  • Localizes data access for users around the world

Differences between Relational and NoSQL Database

Azure Cosmos DB is a NoSQL database service while Azure SQL Database is a relational database service. There are some key differences between these two types of databases:

Data Model

  • Relational databases like Azure SQL Database have a predefined schema where data is organized into tables with rows and columns. Relationships can be defined between tables.
  • NoSQL databases like Azure Cosmos DB have a flexible schema. Data is stored in documents similar to JSON with no requirements for a fixed schema.

Scalability

  • Relational databases can scale vertically by adding more resources like CPU, memory to a single server. Scaling out requires data sharding techniques.
  • NoSQL databases like Cosmos DB scale horizontally across servers to handle large volumes of reads and writes easily. Cosmos DB provides automatic partitioning of data as well as replication across regions.

Querying

  • Relational databases support powerful querying via SQL language. Complex joins, aggregations can be performed.
  • NoSQL databases have limited query capabilities. Cosmos DB provides SQL like querying but complex operations may not be feasible.

Consistency

  • Relational databases typically maintain strong consistency where writes are guaranteed to be successful before a transaction is committed.
  • NoSQL databases often sacrifice strong consistency for higher availability and lower latency. Cosmos DB provides multiple well-defined consistency models to balance tradeoffs.

In summary, if your application needs ACID transactions, complex querying, and fixed schema, choose a relational database like Azure SQL. For flexible schemas, horizontal scaling, and fast reads/writes across regions, choose a NoSQL database like Azure Cosmos DB. The data model and use case should drive the database choice.

Distributed Database

Azure Cosmos DB is a fully managed, globally distributed database service that provides turnkey global distribution, elastic scaling, single-digit millisecond response times, and automatic indexing over schema-agnostic data models.

Some key features that make Cosmos DB an excellent choice for distributed databases are:

Multi-model API support

  • Azure Cosmos DB supports document, key-value, wide-column, and graph data models via its API offerings like SQL, MongoDB, Cassandra, Gremlin etc. This provides flexibility to choose the right API for your application needs.

Turnkey Global Distribution

  • Data is automatically distributed across Azure regions worldwide. This enables low latency access to data from anywhere, high availability, and elastic scaling of throughput and storage worldwide.

Guaranteed Speed at Scale

  • Latency guarantees ensure fast response times to your globally distributed data. As you scale data worldwide, Cosmos DB guarantees single-digit millisecond latencies at the 99th percentile.

Serverless and Automatic Scaling

  • Azure Cosmos DB is serverless, automatically scaling throughput and storage across regions. You don’t have to manage servers or data shards.

Five Consistency Models

  • Choose from five well-defined consistency models to balance availability, latency, throughput and consistency based on your application needs.

Multi Model Database

Azure Cosmos DB is a highly scalable and high-performance multi-model database service provided by Microsoft Azure. It supports multiple data models including document, key-value, graph, and columnar, making it a very versatile database option for modern applications.

Key features of Azure Cosmos DB that make it a great multi-model database option:

  • Supports document, key-value, wide-column, and graph data models in a single service. This allows you to use the right data model for your application needs without needing separate database services.
  • Fully managed and serverless. Cosmos DB is a Platform-as-a-Service (PaaS) offering that handles infrastructure and database administration tasks so developers can focus on application logic.
  • Guaranteed single-digit millisecond response times at any scale. Unique multi-master replication technology delivers high availability and low latency globally.
  • Automatic and instant scalability of throughput and storage across any number of geographical regions. This elastic scalability allows applications to easily meet demand spikes.
  • Comprehensive SLAs covering throughput, latency, availability and consistency. This ensures predictable database performance.
  • Secure by default with support for encryption, role-based access control, and network isolation. Meets regulatory compliance needs.

How does Azure Cosmos DB work?

Azure Cosmos DB is a fully managed NoSQL database service that provides fast and reliable performance at global scale. Here is a step-by-step explanation of how Cosmos DB works:

Data model

  • Azure Cosmos DB supports different data models like key-value, document, graph, and column-family. This allows you to store and query data in a schema-agnostic manner.

Global distribution

  • Data in Azure Cosmos DB is distributed across multiple Azure regions for high availability and low latency access. It replicates data seamlessly to any number of regions of your choice.

Horizontal scaling

  • Azure Cosmos DB scales storage and throughput elastically on demand. It allows storage and throughput to scale independently to meet the needs of your workload.

Guaranteed performance

  • Azure Cosmos DB provides single-digit millisecond response times at the 99th percentile. It offers comprehensive service level agreements (SLAs) for throughput, consistency, availability and latency.

Fully managed service

  • As a fully managed cloud service, Cosmos DB handles infrastructure maintenance including operating system, database engine, and replication. You only pay for the throughput and storage you need.

Secure by default

  • Azure Cosmos DB provides enterprise-grade security including encryption at rest and in transit as well as role-based access control and support for private endpoints.

Data Provisioning

Provisioning data in Azure Cosmos DB can be easily achieved through its flexible APIs and integrations. Here are some key ways to provision data into Cosmos DB for optimal performance and cost efficiency:

Use the appropriate API

Azure Cosmos DB provides five APIs – SQL, MongoDB, Cassandra, Gremlin, and Table – allowing you to use your preferred programming model. Choose the right API based on your data and workload needs for optimal provisioning.

Automate data ingestion

You can set up automated data pipelines to move large datasets into Cosmos DB using Azure Data Factory or functions. This ensures smooth, continuous data ingestion without manual effort.

Optimize throughput

Provision enough throughput capacity to handle your workload’s peak requirements. You can scale up and down anytime. Use autoscale to right-size throughput automatically based on usage patterns. This optimizes cost.

Take advantage of integrations

Integrations with Azure services like Cognitive Search, Machine Learning, and Logic Apps simplify importing data from multiple sources into Cosmos DB. Less coding, faster provisioning.

Implement partitioning

Partition your data in Azure Cosmos DB to allow smooth scalability and high throughput. Choose the right partition key and partition strategy to optimize data distribution and load balancing.

By following these best practices, you can reliably and efficiently provision all kinds of data into Cosmos DB for serving modern applications. The flexible provisioning options ensure you only pay for what you need.

Common Use Cases

Azure Cosmos DB is a highly scalable and performant NoSQL database service on Azure that is commonly used for the following use cases:

Real-time applications
Azure Cosmos DB provides single-digit millisecond response times at any scale, making it ideal for building responsive real-time web and mobile applications. Its automatic indexing and tunable consistency levels allow you to optimize read and write speeds.

IoT and telemetry data
Azure Cosmos DB ingests billions of data points per day from internet-connected devices and sensors. Its schema-agnostic data model and turnkey global distribution make Cosmos DB a great fit for ingesting, processing, and analyzing IoT telemetry data streams globally.

Gaming applications
Azure Cosmos DB delivers predictable low latency and high availability for handling the write-heavy workloads of gaming applications. Its multi-master replication and 99.999% high availability guarantee ensure uninterrupted access for gamers worldwide.

Retail and marketing applications
Azure Cosmos DB enables building highly personalized retail experiences by running lightning-fast queries on petabytes of operational and analytical data. Its elastic scalability, global distribution, and multi-model APIs accelerate development.

Web and mobile applications
Azure Cosmos DB provides the foundation for rapidly building and updating web and mobile apps. Its schema-free data model, rich APIs, and automatic indexing accelerate app development without managing schemas or index management.

With features like guaranteed speed at any scale, tunable consistency levels, automatic indexing, and multi-region replication, Cosmos DB is optimized to power mission-critical cloud applications. Its proven performance, scalability, high availability, and ease of use make it the right choice for modern applications.

Conclusion of Azure Cosmos DB

Azure Cosmos DB is a highly scalable and performant NoSQL database service offered by Microsoft Azure. It provides turnkey global distribution, elastic scaling of throughput and storage, single-digit millisecond response times, and guaranteed high availability – all backed by industry-leading SLAs.

Cosmos DB removes the barriers that have traditionally slowed the development and adoption of globally distributed database applications. Its unique combination of features makes it a great choice as the database engine for web, mobile, gaming, and IoT applications requiring elastic scaling, global replication, and predictable performance guarantees.

ABOUT THE AUTHOR: Dennis Earhart I am an IT expert with over 10 years of experience in the IT industry. As an affiliate marketer, I share exam questions and study guides for major IT vendors including Dell, HP, Microsoft, Amazon and more. My goal is to help IT professionals advance their careers by providing the resources they need to gain certifications from top tech companies.

RELATED POSTS

LEAVE YOUR COMMENT

Your email address will not be published. Required fields are marked *