Courseiva

C100DEV MongoDB Overview and Document Model Practice Question

A developer is building a MongoDB application that tracks server metrics. Each metric document must include a timestamp, and the application frequently queries metrics for a specific server within a date range. The developer wants to ensure that the timestamp field is stored in a way that supports efficient range queries and sorting. Which BSON data type should the timestamp field use?

⚠ Common exam trap

Watch out — candidates often confuse the BSON Timestamp type, which is for internal replication, with the Date type intended for application timestamps.

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

✓

Date

The BSON Date type is the correct choice because it stores time as a 64-bit integer (milliseconds since epoch), enabling efficient range queries and sorting. It is the standard type for timestamps in MongoDB applications and is fully supported by query and aggregation operators. The Timestamp type is reserved for internal use, while String and Long would require manual handling and lack native date functionality.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    String

    Why it's wrong here

    Storing the timestamp as a String (e.g., ISO 8601 format) would allow range queries only if the strings are consistently formatted and lexicographically sortable. However, string comparisons are generally slower than numeric comparisons, and the application would need to parse the string to perform date arithmetic. This approach also risks inconsistencies if different formats are used, and it does not leverage MongoDB's built-in date operators.

  • ✗

    Timestamp

    Why it's wrong here

    The BSON Timestamp type is a special internal type used by MongoDB for replication and sharding (e.g., oplog entries). It consists of a 4-byte seconds value and a 4-byte increment, but it is not intended for application-level date storage. While it can store time, it lacks the precision and standard date operations that the Date type provides, and using it for range queries on application timestamps is not recommended.

  • ✓

    Date

    Why this is correct

    The BSON Date type stores a 64-bit integer representing milliseconds since the Unix epoch (January 1, 1970). This numeric representation allows MongoDB to efficiently compare and sort dates, making it ideal for range queries on timestamps. Using Date ensures that queries like finding metrics between two dates are optimized and accurate, and it integrates seamlessly with MongoDB's query operators such as $gt and $lt.

  • ✗

    Long

    Why it's wrong here

    A Long (64-bit integer) could store milliseconds since the epoch, but it would require the application to manually convert between numeric values and date representations. MongoDB's Date type is specifically designed for this purpose and offers dedicated query operators and aggregation framework support. Using Long adds unnecessary complexity and loses the semantic meaning of a date, making it harder to work with in queries and updates.

About these practice questions

This C100DEV question is part of Courseiva's 259-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 →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official MongoDB exam blueprint

This C100DEV practice question is part of Courseiva's free MongoDB 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 C100DEV exam.