Question 1
Topic: Philosophy & Features
Skill tested: Compares JSON and BSON representation tradeoffs for document storage and query performance.
A telemetry service stores device readings as MongoDB documents and frequently filters on a numeric timestamp, a Boolean health flag, and nested numeric sensor values. The application team proposes retaining a JSON-formatted copy of every record in a string field because JSON is human-readable and easy to exchange. The collection is large, and the operational requirement is to query these fields directly without parsing each record in application code. The team also wants to preserve efficient storage and traversal of typed values. Which design best meets these requirements?
MongoDB stores documents in BSON, a binary representation that supports typed values and efficient traversal, so numeric and Boolean fields can be queried and indexed directly. A JSON string is just a scalar string to MongoDB; its internal properties are not independently queryable or indexable as document fields. Encoding everything as text discards useful type information, while storing duplicate complete representations increases storage and write costs without helping the stated query requirement. JSON remains useful for interchange, but the queryable collection should use structured BSON documents.