MCQs on Querying and Development with Azure Cosmos DB | Azure Cosmos DB MCQs Questions

Azure Cosmos DB is a globally distributed, multi-model database service designed for modern app development. This guide offers 30 carefully selected Azure Cosmos DB MCQ questions and answers covering SQL API querying, SDK usage, CRUD operations, triggers, UDFs, and query optimization. Perfect for developers, these questions will enhance your understanding of efficient Cosmos DB usage.


MCQs

1. Writing Queries with SQL API

  1. Which SQL API keyword is used to query data from a container in Azure Cosmos DB?
    a) SELECT
    b) GET
    c) FETCH
    d) QUERY
  2. What is the purpose of the “OFFSET LIMIT” clause in Cosmos DB SQL API?
    a) Sorting results
    b) Pagination of query results
    c) Joining two containers
    d) Filtering specific fields
  3. Which type of clause does Cosmos DB SQL API use to filter query results?
    a) GROUP BY
    b) WHERE
    c) HAVING
    d) FILTER
  4. In Cosmos DB SQL API, which function calculates the total number of items in a container?
    a) COUNT()
    b) SUM(
    )
    c) TOTAL()
    d) AGGREGATE()
  5. What is returned by the SELECT statement in Azure Cosmos DB SQL API?
    a) Rows
    b) JSON documents
    c) Scalar values
    d) Arrays
  6. How can you retrieve a specific property from a JSON document in Cosmos DB SQL API?
    a) Using the EXTRACT function
    b) Referencing the property by name
    c) Using a JOIN clause
    d) By calling a UDF

2. Working with SDKs: .NET, Java, Python, Node.js

  1. Which of the following is a supported SDK for Azure Cosmos DB?
    a) PHP SDK
    b) .NET SDK
    c) Ruby SDK
    d) Swift SDK
  2. In the .NET SDK, what method is used to create a new container in Cosmos DB?
    a) CreateDatabaseAsync()
    b) CreateContainerAsync()
    c) AddContainerAsync()
    d) InitializeContainerAsync()
  3. Which Java SDK class is used to perform queries in Azure Cosmos DB?
    a) CosmosQueryClient
    b) CosmosDatabaseQuery
    c) CosmosAsyncContainer
    d) CosmosTableQuery
  4. In Python SDK, how do you connect to an Azure Cosmos DB account?
    a) Using the connect_to_cosmos() function
    b) By initializing a CosmosClient object
    c) With the cosmos.connect() method
    d) Through REST APIs
  5. Which Node.js package is used for Azure Cosmos DB integration?
    a) @azure/cosmos
    b) azure-sdk-db
    c) cosmos-db-client
    d) cosmos-sdk-node
  6. How do you execute a stored procedure using the .NET SDK?
    a) ExecuteStoredProcedureAsync()
    b) RunStoredProcedure()
    c) CallProcedure()
    d) ExecuteProcedureAsync()

3. CRUD Operations and Stored Procedures

  1. What is the method to create a document in Cosmos DB using SQL API?
    a) INSERT INTO
    b) ADD ITEM
    c) CREATE DOCUMENT
    d) POST ITEM
  2. Which SDK operation is used to update a document in Azure Cosmos DB?
    a) ReplaceItemAsync()
    b) ModifyDocument()
    c) UpdateRecord()
    d) PatchItemAsync()
  3. How does Azure Cosmos DB ensure uniqueness of a document?
    a) By using the partition key and id property
    b) By automatically indexing all properties
    c) Through primary key constraints
    d) Using stored procedures
  4. Which operation is required to delete a container in Cosmos DB?
    a) DeleteContainerAsync()
    b) DropTable()
    c) RemoveCollection()
    d) DestroyContainer()
  5. In Cosmos DB, stored procedures are written in:
    a) SQL
    b) JavaScript
    c) Python
    d) Java
  6. What is the benefit of using stored procedures in Cosmos DB?
    a) Distributed transaction management
    b) Index management
    c) Performing operations within a single partition
    d) Increasing partition count

4. Using Triggers and User-Defined Functions (UDFs)

  1. Triggers in Azure Cosmos DB are executed:
    a) Before or after an operation
    b) Only before an operation
    c) Only after an operation
    d) Independently of operations
  2. What is the purpose of UDFs in Cosmos DB?
    a) To define schema constraints
    b) To apply custom logic during queries
    c) To manage containers
    d) To control access permissions
  3. UDFs in Cosmos DB are written in:
    a) SQL
    b) JavaScript
    c) Python
    d) C#
  4. How are triggers associated with operations in Cosmos DB?
    a) By specifying the trigger name during the operation
    b) Through host.json configurations
    c) Using a trigger binding in SDKs
    d) Triggers are automatically applied
  5. Which SDK method is used to create a trigger in Cosmos DB?
    a) CreateTriggerAsync()
    b) DefineTrigger()
    c) AddTrigger()
    d) InitializeTriggerAsync()
  6. When should you use a post-trigger in Cosmos DB?
    a) To validate data before insertion
    b) To log changes after an operation
    c) To aggregate data across partitions
    d) To modify indexing policies

5. Optimizing Query Performance

  1. How can you improve query performance in Azure Cosmos DB?
    a) By using proper indexing
    b) By reducing partition count
    c) Using a relational schema
    d) Avoiding JSON format
  2. What is the purpose of the partition key in Cosmos DB?
    a) To manage indexing
    b) To distribute data across partitions
    c) To secure the database
    d) To perform bulk operations
  3. Which indexing mode is default in Azure Cosmos DB?
    a) Manual
    b) Automatic
    c) Lazy
    d) No Index
  4. What tool helps monitor query performance in Cosmos DB?
    a) Azure Monitor
    b) Query Metrics in Azure Portal
    c) Azure Storage Explorer
    d) Log Analytics
  5. Which consistency level offers the lowest latency in Cosmos DB?
    a) Eventual
    b) Strong
    c) Bounded Staleness
    d) Session
  6. How can you reduce RU (Request Units) consumption for queries?
    a) Reducing payload size
    b) Using selective projections
    c) Optimizing the partition key
    d) All of the above

Answers

QNoAnswer (Option with the text)
1a) SELECT
2b) Pagination of query results
3b) WHERE
4a) COUNT(*)
5b) JSON documents
6b) Referencing the property by name
7b) .NET SDK
8b) CreateContainerAsync()
9c) CosmosAsyncContainer
10b) By initializing a CosmosClient object
11a) @azure/cosmos
12a) ExecuteStoredProcedureAsync()
13c) CREATE DOCUMENT
14a) ReplaceItemAsync()
15a) By using the partition key and id property
16a) DeleteContainerAsync()
17b) JavaScript
18c) Performing operations within a single partition
19a) Before or after an operation
20b) To apply custom logic during queries
21b) JavaScript
22a) By specifying the trigger name during the operation
23a) CreateTriggerAsync()
24b) To log changes after an operation
25a) By using proper indexing
26b) To distribute data across partitions
27b) Automatic
28b) Query Metrics in Azure Portal
29a) Eventual
30d) All of the above

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top