Describe considerations for working with non-relational data on Azure →mediumMultiple ChoiceObjective-mapped
Azure Cosmos DB Partition Key Selection for Common Query Patterns
A travel booking application stores booking data in Azure Cosmos DB using the NoSQL API. Each booking document contains: BookingID (unique), UserID, Destination, TravelDate, Price. The most common query is: 'Retrieve all bookings for a specific UserID, sorted by TravelDate descending.' To minimize Request Unit (RU) consumption, which property should be chosen as the partition key?
Quick Answer
The answer is UserID. This is the correct partition key because the most common query pattern filters on UserID, and Azure Cosmos DB can route the query directly to the single physical partition containing that user’s data, avoiding costly cross-partition fan-out and minimizing Request Unit consumption. On the Microsoft Azure Data Fundamentals DP-900 exam, this scenario tests your understanding that partition key selection must align with the primary query filter to achieve efficient, single-partition queries. A common trap is choosing BookingID because it is unique, but that would scatter each booking across partitions, forcing a fan-out for every UserID-based query. Remember the memory tip: “Filter first, partition key follows”—always pick the property you filter by most often, not the one that is simply unique.
⚠ Common exam trap
The trap here is that candidates often pick a high-cardinality key like BookingID or a date-based key like TravelDate, thinking uniqueness or time-ordering helps, but they ignore that the partition key must match the most frequent query filter to avoid cross-partition queries and high RU costs.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
UserID
UserID is the correct partition key because the most common query filters on UserID, and Cosmos DB routes queries to the exact physical partition(s) containing that UserID's data. This minimizes cross-partition fan-out, reducing RU consumption. A partition key should align with the primary query filter to enable efficient point-read or single-partition query execution.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
BookingID
Why it's wrong here
BookingID is unique, so queries by UserID would become cross-partition scans, increasing RU consumption as the service must fan out to all partitions.
- ✓
UserID
Why this is correct
UserID is the filter in the common query. With UserID as partition key, all bookings for a user reside in one partition, making queries efficient and reducing RU consumption.
- ✗
Destination
Why it's wrong here
Destination may group bookings from multiple users, but the query filters by UserID, not Destination. Using Destination would lead to cross-partition queries for UserID filters.
- ✗
TravelDate
Why it's wrong here
TravelDate has high cardinality but is not the filter field. Queries filtering by UserID would still need to access multiple partitions, increasing RU consumption.
Go deeper
Related to this question
Learn chapter
Data Roles and Core Concepts
Key term
Azure Cosmos DB
Azure Cosmos DB is a fully managed, globally distributed NoSQL database service that offers fast reads and writes anywhere in the world with automatic scaling and multiple consistency models.
Key term
Data
Data is raw, unprocessed information, like numbers, words, or measurements, that can be stored, processed, and analyzed by computers.
About these practice questions
Courseiva writes every DP-900 question from scratch — 820 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
4 more ways this is tested on DP-900
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A travel booking application stores user itineraries in Azure Cosmos DB using the NoSQL API. Each itinerary document contains: UserID (unique to user), ItineraryID, Destination, BookingDate, and a nested array of Activities. The most common query is: 'Retrieve all itineraries for a specific UserID sorted by BookingDate descending.' To minimize Request Unit (RU) consumption, which partition key should be chosen?
medium- A.ItineraryID
- ✓ B.UserID
- C.Destination
- D.BookingDate
Why B: UserID is the correct partition key because the most common query filters on UserID, ensuring that all itineraries for a specific user are stored in the same physical partition. This allows the query to target a single partition, minimizing cross-partition queries and reducing Request Unit (RU) consumption. A partition key that aligns with the primary query filter is essential for optimal performance and cost efficiency in Azure Cosmos DB.
Variation 2. A ride-sharing application uses Azure Cosmos DB for trip data. Each trip record contains TripID (unique), DriverID, RiderID, TripDate, and other details. The most common query retrieves all trips for a specific driver within a given date range. Which partition key should be chosen to minimize Request Unit (RU) consumption and ensure even data distribution?
medium- A.TripID
- ✓ B.DriverID
- C.TripDate
- D.RiderID
Why B: DriverID is the optimal partition key because the most common query filters on DriverID and a date range. Partitioning by DriverID ensures that all trips for a specific driver are stored in the same physical partition, making the query a single-partition operation that consumes minimal Request Units (RUs). It also provides even data distribution across partitions because each driver generates a roughly similar number of trips, avoiding hot spots.
Variation 3. A social media application stores user posts in Azure Cosmos DB using the NoSQL API. Each document includes: PostID (unique), UserID, Timestamp, Content. The most common query is: 'Get all posts for a specific UserID, sorted by Timestamp descending.' Which partition key should be chosen to distribute load evenly across physical partitions while also supporting this query efficiently?
medium- A.PostID
- ✓ B.UserID
- C.Timestamp
- D.Content
Why B: UserID is the correct partition key because it evenly distributes write operations across physical partitions (each user has a unique ID) and directly supports the most common query: filtering by UserID. With UserID as the partition key, the query 'Get all posts for a specific UserID, sorted by Timestamp descending' becomes a single-partition query (using the partition key in the WHERE clause), which is efficient and avoids cross-partition fan-out. This design also allows Cosmos DB to use the Timestamp field as a sort key within each logical partition, enabling efficient sorting without additional indexing overhead.
Variation 4. A social media application stores user profiles in Azure Cosmos DB using the NoSQL API. Each profile includes UserID, Name, Email, and an array of Posts. The most common query retrieves a user's profile by UserID. The application requires strong consistency for writes so that once a profile is updated, all subsequent reads see the latest data. To minimize Request Unit (RU) consumption, which partition key should be chosen?
medium- ✓ A.UserID
- B.Email
- C.Name
- D.A synthetic partition key combining UserID and Region
Why A: UserID is the correct partition key because it is the primary filter in the most common query (retrieving a profile by UserID), ensuring each query targets a single logical partition. This minimizes cross-partition queries and RU consumption. Additionally, UserID provides high cardinality and even distribution, which prevents hot partitions and supports the required strong consistency for writes.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DP-900 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DP-900 exam.