Question

Difficulty: EasyConfigure Partition Keys and Partitioning Strategies in Azure Cosmos DB

You are designing an Azure Cosmos DB container to store reservation records for a hotel management system. Each reservation includes the fields `hotelId`, `guestId`, `reservationDate`, and `status`. You need to configure the container to support multi-document transactional batches for reservations at the same hotel, while avoiding hot partitions.

Which two configuration choices should you make? (Select two.)

  1. Set the partition key of the container to `/hotelId`Answer
  2. Ensure that all operations within a single transactional batch specify the same `/hotelId` valueAnswer
  3. C
    Set the partition key of the container to `/status` to group reservations by their current state
  4. D
    Execute transactional batch operations across different `/hotelId` values to update multiple hotels in one transaction

Answer

Configure the container with `/hotelId` as the partition key and ensure all operations in a transactional batch target the same `/hotelId` value.
To support transactional batches for reservations at the same hotel, the container must be partitioned by `/hotelId` so that all reservations for a given hotel reside in the same logical partition. Furthermore, all operations within a transactional batch must target this same partition key value, as transactional batches cannot span multiple logical partitions.

Step-by-Step Solution

1
Analyze the transactional requirement
Multi-document transactions in Azure Cosmos DB (using transactional batches) require all involved documents to share the same partition key value (i.e., reside in the same logical partition).
Since the transactions must be executed for reservations at the same hotel, the partition key must group reservations by hotel, pointing to `/hotelId`.
2
Verify partitioning rules for transactional batches
All operations in a transactional batch must target the same partition key value. Therefore, you must ensure all operations in the batch use the same `/hotelId`.
Cross-partition transactional batches are not supported in Azure Cosmos DB.
3
Evaluate distractors for partition key suitability
Partitioning by `/status` is rejected due to low cardinality (leading to hot partitions), and cross-partition transactions are structurally impossible.
Ensures the system remains scalable and performs within transactional boundary constraints.

Key Concept

Azure Cosmos DB partition keys must be chosen to align with transactional boundaries (which are limited to a single logical partition) while avoiding hot partitions by ensuring sufficient cardinality.
Estimated Time:1m 0s
Rate this question