Azure Cosmos DB Interview Questions
What is Azure Cosmos DB?
How can we use REST to query a resource?
What is azure cosmos db emulator?
What is azure cosmos db container?
What do you mean by Cosmos DB Container Partition Keys?
What is Throughput in Cosmos DB and it types?
What is consistency level in Cosmos DB?
What are the different levels of consistency available in Cosmos DB?
Q: What is Azure Cosmos DB?
Ans:
Microsoft's Azure Cosmos DB is a fast NoSQL database with open APIs that can extend to any scale. The service is designed to allow clients to extend throughput and storage across any number of geographical locations flexibly (and independently).
Q: How can we use REST to query a resource?
Ans:
To run a SQL query on a resource, follow these steps:
- Use JSON with the query property set to the SQL query string to perform POST method against a resource path, and the "parameters" property to an array of optional parameter values.
- Set the
x-ms-documentdb-isquery
header to True. - Set the Content-Type header to
application/query+json
.
POST https://contosomarketing.documents.azure.com/dbs/XP0mAA==/colls/XP0mAJ3H-AA=/docs HTTP/1.1
x-ms-documentdb-isquery: True
x-ms-date: Mon, 18 Apr 2024 13:05:49 GMT
authorization: type3dkOU%2bBn2vkvIlHypfE8AA5fulpn8zKjLwdrxBqyg0YGQ%3d
x-ms-version: 2015-12-16
x-ms-query-enable-crosspartition: True
Accept: application/json
Content-Type: application/query+json
Host: contosomarketing.documents.azure.com
Content-Length: 50
{
"query": "SELECT * FROM root WHERE (root.Author.id = 'John')",
"parameters": []
}
Take a look at our suggested post :
Q: What is azure Cosmos DB emulator?
Ans:
The Azure Cosmos DB Emulator emulate the Azure Cosmos DB service with excellent fidelity. It has the same capability as Azure Cosmos DB, including the ability to create data, query data, provision and scale containers, and run stored procedures and triggers.
Q: What is azure cosmos db container?
Ans:
CosmosDB containers are the database units that determine scalability in terms of both throughput and storage. Containers are partitioned horizontally and then replicated across different regions. The items (document, node, or row) inside a container are automatically distributed depending on the partition key.
Q: What do you mean by Cosmos DB Container Partition Keys?
Ans:
The logical distribution of an item is determined by Partition Keys. With logical partitions,
each item in a container has a unique item ID. It's important to note that after the container
is formed, you can't change the partition key. To modify it, you'd have to delete and recreate
the container.
Cosmos DB supports two kinds of partitions: logical partitions and physical partitions.
Q: What is Throughput in Cosmos DB and it types?
Ans:
The quantity of queries that a cosmos account can support is defined by its throughput. Cosmos DB currently supports two throughput modes: manual and auto-scale. Rate limits may apply if your resource utilises more throughput than is allocated. To handle the changing demands of the application, you may either adjust the throughput manually or set it to autoscale.
Q: What is consistency level in Cosmos DB?
Ans:
In CosmosDB, consistency is defined as the uniformity of data when it is replicated across the globe to various regions. It specifies when and how data is copied and committed to a replica.
Q: What are the different levels of consistency available in Cosmos DB?
Ans:
Azure Cosmos DB lets you select a consistency level that provides a good combination of latency, throughput, and availability for your needs. The various levels of consistency available are as follows:
- Strong Consistency: Ensures consistency throughout all nodes and regions, though at the expense of overall performance.
- Staleness with a Boundary Consistency: Provides a method for controlling the level of freshness of data. However, based on the level of freshness selected, this is still a strong consistency. There would be possibility of Dirty reads.
- Session Consistency: Makes sure that there are no dirty reads for the writer, although other users may have dirty reads. This is the Azure Cosmos DB's default consistency level.
- Consistent Prefix: Makes sure that all replicas' read data has been updated. Out-of-order writes are never seen by readers at this level.
- Eventual Consistency: There are no assurances on the accuracy of the data or the order. This, however, delivers the fastest performance.