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 mobile gaming company stores player data in Azure Cosmos DB using the Core (SQL) API. Each document contains fields: playerId, nickname, score, level, and an inventory array of item objects (each with name and type). The company wants to query all players whose score is above 5000 and who have a specific item (e.g., a sword) in their inventory. Which query clause should they use?
⚠ Common exam trap
Watch out — candidates often confuse SQL array syntax (like IN or direct property access) with the specialized ARRAY_CONTAINS function required for querying arrays of objects in Cosmos DB, or they mistakenly apply JavaScript array methods that are not supported in the SQL API.
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
✓
B) WHERE c.score > 5000 AND ARRAY_CONTAINS(c.inventory, {name: 'sword'}, true)
ARRAY_CONTAINS with the third parameter set to 'true' performs a partial match, checking if any element in the inventory array has a 'name' property equal to 'sword'. This is the standard way to query for an item within an array of objects in Azure Cosmos DB's SQL API, as it correctly handles the nested structure without requiring a JOIN or subquery.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A) WHERE c.score > 5000 AND c.inventory.some(item => item.name == 'sword')
Why it's wrong here
This expression uses JavaScript-style arrow function syntax, which is not part of the Cosmos DB SQL API grammar. The function c.inventory.some() is not recognized by the query engine—Cosmos DB does not allow lambda expressions or method callbacks within the WHERE clause. This pattern is more typical of MongoDB's query language or client-side JavaScript, and it will be rejected as a syntax error by Cosmos DB. Native alternatives that do work include ARRAY_CONTAINS for simple checks and EXISTS (SELECT VALUE item FROM item IN c.inventory WHERE item.name = 'sword') or JOIN for more detailed filtering.
When this WOULD be correct
If the question were about a MongoDB API query using the `$where` operator or a client-side filter in application code (e.g., LINQ in C#), then using `some()` or similar array iteration would be valid.
- ✓
B) WHERE c.score > 5000 AND ARRAY_CONTAINS(c.inventory, {name: 'sword'}, true)
Why this is correct
This is the only correct predicate. The ARRAY_CONTAINS function in Cosmos DB SQL API scans the c.inventory array and, when the third argument is true, performs a partial match against the specified object {name: 'sword'}. Partial matching means any inventory element that has a name property equal to 'sword' will satisfy the condition, even if that element also contains other fields like durability or price. This makes ARRAY_CONTAINS the intended, index-aware way to filter documents based on nested object properties within an array.
- ✗
C) WHERE c.score > 5000 AND c.inventory.name == 'sword'
Why it's wrong here
This syntax is invalid in Cosmos DB SQL API because dot notation on an array property (c.inventory.name) attempts to access a member called name on the entire array itself, not on each individual element. The query engine treats c.inventory as a single JSON array value, and arrays do not expose object properties like name, so this expression causes a query compilation error or returns no results depending on the exact context. The correct way to inspect object properties within an array is to use ARRAY_CONTAINS, JOIN, or EXISTS with a subquery—plain property navigation is only valid for JSON objects.
When this WOULD be correct
This option would be correct if the inventory field were a single object (not an array) containing a name property, e.g., each document has inventory: {name: 'sword', type: 'weapon'}. The query would then check if that single object's name equals 'sword'.
- ✗
D) WHERE c.score > 5000 AND 'sword' IN c.inventory
Why it's wrong here
The IN operator in Cosmos DB SQL API compares a scalar left-hand expression against each element of an array or subquery result. Here the left side is the string 'sword' and the right side is c.inventory, which is an array of objects. Since each element is a JSON object, not a scalar string, the equality comparison always fails and the query returns no results. IN is useful only for scalar lists, such as WHERE c.score IN (1000, 2000, 5000), and cannot be used to test properties of objects inside an array.
When this WOULD be correct
If the inventory array contained only item names as strings (e.g., ['sword', 'shield']), then WHERE 'sword' IN c.inventory would correctly filter documents where the array includes that string.
Option-by-option analysis
Why each answer is right or wrong
Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The DP-900 exam frequently reuses these exact scenarios with slightly different constraints.
✓B) WHERE c.score > 5000 AND ARRAY_CONTAINS(c.inventory, {name: 'sword'}, true)Correct answer▾
Why this is correct
This is the only correct predicate. The ARRAY_CONTAINS function in Cosmos DB SQL API scans the c.inventory array and, when the third argument is true, performs a partial match against the specified object {name: 'sword'}. Partial matching means any inventory element that has a name property equal to 'sword' will satisfy the condition, even if that element also contains other fields like durability or price. This makes ARRAY_CONTAINS the intended, index-aware way to filter documents based on nested object properties within an array.
✗A) WHERE c.score > 5000 AND c.inventory.some(item => item.name == 'sword')Wrong answer — click to see why▾
Why this is wrong here
Azure Cosmos DB SQL API does not support JavaScript arrow functions like `some()` in queries. The correct syntax uses `ARRAY_CONTAINS` with partial document matching.
★ When this WOULD be the correct answer
If the question were about a MongoDB API query using the `$where` operator or a client-side filter in application code (e.g., LINQ in C#), then using `some()` or similar array iteration would be valid.
Why candidates choose this
Candidates familiar with JavaScript array methods may mistakenly assume they can use similar syntax in Cosmos DB SQL queries, not realizing the API uses a restricted SQL-like language.
✗C) WHERE c.score > 5000 AND c.inventory.name == 'sword'Wrong answer — click to see why▾
Why this is wrong here
In Azure Cosmos DB SQL API, c.inventory.name == 'sword' is invalid because inventory is an array of objects, not a single object. This syntax would only work if inventory were a single object with a name property, not an array.
★ When this WOULD be the correct answer
This option would be correct if the inventory field were a single object (not an array) containing a name property, e.g., each document has inventory: {name: 'sword', type: 'weapon'}. The query would then check if that single object's name equals 'sword'.
Why candidates choose this
Candidates may mistakenly think that array properties can be accessed directly with dot notation, similar to nested object properties, not realizing that arrays require special functions like ARRAY_CONTAINS or JOIN to query elements.
✗D) WHERE c.score > 5000 AND 'sword' IN c.inventoryWrong answer — click to see why▾
Why this is wrong here
The IN operator checks if a scalar value exists in an array, but c.inventory is an array of objects, not strings. 'sword' is a string, not an object, so the query will never match.
★ When this WOULD be the correct answer
If the inventory array contained only item names as strings (e.g., ['sword', 'shield']), then WHERE 'sword' IN c.inventory would correctly filter documents where the array includes that string.
Why candidates choose this
Candidates may be familiar with the IN operator from SQL or other languages and assume it works for checking values within arrays of objects, overlooking that it only works for primitive values.
Analysis generated from the official DP-900blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”
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
One of 820 original DP-900 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.