Describe considerations for working with non-relational data on Azure →mediumMultiple ChoiceObjective-mapped
DP-900 Practice Question: Describe considerations for working with non-relational data on Azure
A development team is designing an application that stores user session data in Azure Cosmos DB. Each session document contains a sessionId (unique), userId, timestamp, and a JSON field 'metadata' that can include various optional properties. The application frequently queries by userId to retrieve all sessions for a particular user. Which property should be chosen as the partition key to optimize query performance and ensure even data distribution?
⚠ Common exam trap
Candidates often choose sessionId because it is unique, not realizing that a high-cardinality key that is not used in queries leads to inefficient cross-partition queries, while a key like userId balances query efficiency with distribution.
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
The partition key should be the property most frequently used in queries and that provides high cardinality for even distribution. Since the application frequently queries by userId to retrieve all sessions for a user, choosing userId as the partition key ensures that all session documents for a given user are stored in the same logical partition, making these queries efficient and fast. Additionally, userId typically has a large number of distinct values, which promotes even data distribution across physical partitions.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
sessionId
Why it's wrong here
Using sessionId as the partition key scatters each session document into its own partition, so any query filtering by userId must fan out across many physical partitions and merge results, increasing latency and request-unit consumption. Since sessionId is not the application's main access pattern, it optimizes for unique writes rather than efficient reads by user.
- ✓
userId
Why this is correct
userId is the correct partition key because it is the field used in the most common query filter—retrieving a specific user's sessions. All documents for one user share the same logical partition, so an equality filter on userId is routed directly to a single physical partition, producing a fast, low-RU point read. With many distinct users, the workload spreads evenly while keeping each user's related data co-located.
- ✗
timestamp
Why it's wrong here
timestamp is a poor partition key because it tends to create hot partitions: many sessions started in the same second or minute land in the same physical partition, exceeding its throughput limit and causing throttling. It is also rarely the sole filter in the application's queries, so using it forces every userId-based query to become a cross-partition scan, multiplying RU costs and latency.
- ✗
metadata
Why it's wrong here
metadata is not a valid partition key because it is a nested property that varies by document and may be missing entirely; Cosmos DB requires a partition key path that exists in every item and remains immutable. Even when present, metadata values are often low-cardinality or unpredictable, leading to uneven data distribution and inefficient query routing. Therefore it cannot support reliable, even partitioning.
Go deeper
Related to this question
Learn chapter
Data Roles and Core Concepts
Key term
Partition key
A partition key is a value used by database systems to distribute data across multiple storage partitions, enabling faster queries and efficient scaling.
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
This DP-900 question is part of Courseiva's 820-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.