Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
A document contains scores: [{ subject: "Math", mark: 72 }, { subject: "Science", mark: 91 }]. Which filter requires subject: "Math" and mark: { $gt: 80 } to match the same array element?
$inc changes a numeric field by the specified amount while preserving the document's other fields.
Question 28 of 60 · BSON Data Types · Medium
A financial application must store 19.99 without typical binary floating-point rounding. Which BSON value is most appropriate?
Not quite. Try another option.
Answer: NumberDecimal("19.99")
NumberDecimal() creates a BSON Decimal128 value, which is suitable for exact decimal quantities such as monetary amounts.
Question 29 of 60 · BSON Data Types · Medium
A query must compare event times chronologically and use a date index efficiently. How should new event times normally be stored?
Not quite. Try another option.
Answer: As BSON Date values
BSON Date values preserve temporal meaning and support chronological comparisons, date operators, and efficient date indexes.
Question 30 of 60 · BSON Data Types · Medium
A collection uses MongoDB's default _id values. Which statement about an ObjectId is correct?
Not quite. Try another option.
Answer: It is a 12-byte BSON value containing a timestamp component
An ObjectId is a 12-byte value. Its first four bytes represent the creation timestamp.
Question 31 of 60 · BSON Data Types · Medium
A field can contain either an integer or a numeric string. Which query selects only documents where rating is stored as a string?
Not quite. Try another option.
Answer: { rating: { $type: "string" } }
The $type query operator filters documents according to the BSON type of a field.
Question 32 of 60 · Data Modeling in MongoDB · Medium
An order's line items are always displayed with the order, are limited in number, and should remain as they were when purchased. Which model is most suitable?
Not quite. Try another option.
Answer: Embed the line items in the order
Embedding supports reading the order and its bounded line items together and preserves the purchased item details as one aggregate.
Question 33 of 60 · Data Modeling in MongoDB · Medium
Millions of comments belong to articles, and comments are frequently paginated and updated independently. Which modeling choice is most appropriate?
Not quite. Try another option.
Answer: Store comments separately with an article reference
A separate comments collection avoids unbounded article documents and supports independent updates, indexing, and pagination.
Question 34 of 60 · Data Modeling in MongoDB · Medium
A user's shipping address and profile settings must be updated atomically in a single operation. Which design best supports this requirement?
Not quite. Try another option.
Answer: Embed both values in the user document
MongoDB guarantees atomicity for updates to one document, so embedding both values enables a single atomic update.
Question 35 of 60 · Indexes and Query Optimization · Medium
A frequent query is find({ status: "PAID" }).sort({ createdAt: -1 }). Which index best supports both filtering and sorting?
Not quite. Try another option.
Answer: { status: 1, createdAt: -1 }
Placing the equality field first and the sort field second allows the compound index to support the filter and requested sort order.
Question 36 of 60 · Indexes and Query Optimization · Medium
Given a compound index { category: 1, price: 1, rating: -1 }, which query uses the index's longest valid prefix?
A partial index contains only documents matching its filter, reducing index size when queries focus on active accounts.
Question 41 of 60 · Databases · Hard
An administrator runs use telemetry in mongosh, then immediately checks show dbs. The telemetry database is absent. Which explanation is correct?
Not quite. Try another option.
Answer: use selects a database handle, but the database is materialized only after data or a collection is created.
use telemetry changes the current database context without persisting a database. An operation such as db.createCollection(...) or an insert materializes it.
Question 42 of 60 · Creating and Dropping Databases and Collections · Hard
A script connects with db currently set to staging and executes db.dropDatabase(). It then inserts into db.events without issuing another use command. What is the expected result?
Not quite. Try another option.
Answer: The insert recreates staging and implicitly creates the events collection.
Dropping the database removes its stored contents but does not change the shell's current database handle. A later insert can recreate both the database and collection.
Question 43 of 60 · Collections · Hard
A collection has a JSON Schema validator and two secondary indexes. It is dropped and then recreated by inserting its first document. Which state should be expected?
Not quite. Try another option.
Answer: Neither the validator nor the secondary indexes return automatically after recreation.
Dropping a collection removes its documents, indexes, and collection options. An implicit recreation starts with default options and only the automatic _id index.
Question 44 of 60 · Documents · Hard
Given documents {_id: 1, x: null}, {_id: 2}, and {_id: 3, x: 0}, which query matches only the document where x explicitly has the BSON null value?
Not quite. Try another option.
Answer: {x: {$type: 10}}
{x: null} matches both null and missing fields. BSON type code 10 selects fields whose stored value is explicitly null.
Question 45 of 60 · BSON Data Types · Hard
A financial application must store 0.1 and perform server-side arithmetic without binary floating-point approximation. Which BSON type is most appropriate?
Not quite. Try another option.
Answer: Decimal128, because it represents decimal fractions with decimal semantics
Decimal128 is designed for decimal arithmetic and can represent values such as 0.1 exactly within its precision. A BSON double uses binary floating-point.
Question 46 of 60 · BSON Data Types · Hard
Two clients insert the same instant using BSON Date values, one from UTC and one from a +05:30 local time converted correctly by its driver. How are these values stored?
Not quite. Try another option.
Answer: As the same signed millisecond value measured relative to the Unix epoch
A BSON Date stores a signed 64-bit count of milliseconds since the Unix epoch. It does not retain the client's original time-zone identifier or offset.
Question 47 of 60 · BSON Data Types · Hard
Why is sorting by a default ObjectId _id only an approximation of sorting by exact creation time?
Not quite. Try another option.
Answer: ObjectIds contain a seconds-level timestamp, while other components determine order within a second.
The leading ObjectId timestamp has one-second resolution. Values generated within the same second are ordered by process-specific and counter components, not an exact global creation time.
Question 48 of 60 · Documents · Hard
A document contains items: [{sku: "A", qty: 2}, {sku: "B", qty: 20}]. Which query requires sku: "A" and qty: {$gt: 10} to be satisfied by the same array element?
$elemMatch correlates multiple conditions to one array element. Separate dotted predicates may be satisfied by different elements of the array.
Question 49 of 60 · Documents · Hard
A collection contains {_id: 7, status: "open", total: 40}. What happens when replaceOne({_id: 7}, {_id: 8, status: "closed"}) attempts to replace it?
Not quite. Try another option.
Answer: The replacement fails because the immutable _id value would be changed.
Replacement updates may remove omitted fields, but they cannot change an existing document's immutable _id value.
Question 50 of 60 · Data Modeling in MongoDB · Hard
An order must preserve the product name and unit price exactly as they were at purchase time, even after the product catalog changes. Which model best supports this requirement?
Not quite. Try another option.
Answer: Embed a snapshot of purchased product details in each order line and retain a product identifier.
Embedding the purchased values preserves historical truth and supports atomic order reads. Retaining the identifier still permits linking the line to the catalog product.
Question 51 of 60 · Data Modeling in MongoDB · Hard
A sensor document appends one reading every second to an embedded array and is retained indefinitely. Which redesign most directly addresses the principal scaling risk?
Not quite. Try another option.
Answer: Move readings into separate time-bucket documents and keep the sensor identifier on each bucket.
An unbounded array causes document growth and can eventually reach the 16 MiB document limit. Bounded time buckets distribute growth while retaining efficient range access.
Question 52 of 60 · Data Modeling in MongoDB · Hard
Users can belong to millions of groups, and groups can contain millions of users. Memberships are frequently added and removed, and queries run in both directions. Which primary model is most robust?
Not quite. Try another option.
Answer: Create a membership collection with one document per user-group relationship.
A relationship collection avoids unbounded arrays on either side and can support both directions with indexes such as {userId: 1, groupId: 1} and {groupId: 1, userId: 1}.
Question 53 of 60 · Indexes and Query Optimization · Hard
A frequent query is find({tenantId: 42, createdAt: {$gte: start}}).sort({score: -1}). Which compound index most closely follows the equality-sort-range guideline?
Not quite. Try another option.
Answer: {tenantId: 1, score: -1, createdAt: 1}
Placing equality fields first and sort fields before range fields lets the index filter by tenant and provide score order before applying the creation-time range.
Question 54 of 60 · Indexes and Query Optimization · Hard
For an index {a: 1, b: -1}, which sort can use the index order directly when there is no filter?
Not quite. Try another option.
Answer: {a: -1, b: 1}
MongoDB can traverse a compound index forward or fully backward. Reversing {a: 1, b: -1} produces {a: -1, b: 1} while preserving field order.
Question 55 of 60 · Indexes and Query Optimization · Hard
A document has both tags: ["red", "sale"] and ratings: [4, 5]. Why can creating the compound index {tags: 1, ratings: 1} fail?
Not quite. Try another option.
Answer: A compound multikey index cannot index more than one array field in the same document.
MongoDB prohibits a compound multikey index when a single indexed document has arrays for more than one indexed field, avoiding a combinatorial key product.
Question 56 of 60 · Indexes and Query Optimization · Hard
With index {tenantId: 1, email: 1}, which query and projection can be covered by that index, assuming no relevant collation or multikey complication?
Not quite. Try another option.
Answer: find({tenantId: 9}, {email: 1, _id: 0})
The filter and returned field are present in the index, and excluding _id avoids fetching it from the document because _id is not part of this index.
Question 57 of 60 · Indexes and Query Optimization · Hard
A partial index is created as {email: 1} with partialFilterExpression: {active: true}. Which query is eligible to use it without a hint?
The optimizer uses a partial index only when the query guarantees that all possible matches satisfy the index filter. Equality to true directly implies the filter.
Question 58 of 60 · Indexes and Query Optimization · Hard
An index on {name: 1} was created with a case-insensitive English collation. A query filters by name but specifies the default simple collation. What is the key optimization consequence?
Not quite. Try another option.
Answer: The index is generally ineligible because the query and index collations do not match.
String comparisons encoded in a collation-aware index follow that collation. A query normally needs the same collation to use the index for those comparisons.
Question 59 of 60 · Indexes and Query Optimization · Hard
Given a standard ascending index on {username: 1}, which predicate is most likely to produce a bounded index scan?
Not quite. Try another option.
Answer: {username: {$regex: /^son/}}
A case-sensitive anchored prefix lets MongoDB derive a lexical range beginning with son. Unanchored, suffix, and case-insensitive patterns generally cannot use the same tight bounds.
Question 60 of 60 · Indexes and Query Optimization · Hard
An explain("executionStats") result shows totalKeysExamined: 200000, totalDocsExamined: 12, and nReturned: 12. What is the strongest conclusion?
Not quite. Try another option.
Answer: The scan uses broad index bounds despite fetching very few documents.
Examining many keys for few results indicates inefficient index traversal or weak bounds. The low document count alone does not make the plan selective or covered.
That's unit 2
Answer a few questions and your score shows up here.
Nearly through. Did unit 2 of CSE494 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 2 of CSE494 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.