Version note: Rewritten September 4, 2026. Verify commands and behavior against the exact MongoDB server, driver, and deployment edition.

NoSQL is an umbrella term for non-relational data models, not “no schema,” automatic scale, or a replacement for SQL. MongoDB stores BSON documents in collections. It can support flexible document structures, indexes, aggregation, replication, sharding, and multi-document transactions, each with design and operational tradeoffs.

Model around access and correctness

Define entities, invariants, query patterns, update frequency, growth, retention, and ownership. Embed data read and updated together when bounded growth and duplication are acceptable; reference data when relationships, independent lifecycle, or unbounded arrays make embedding unsafe. MongoDB’s 16 MiB document limit and index behavior constrain designs.

Validate documents

db.createCollection("orders", {
  validator: {
    $jsonSchema: {
      bsonType: "object",
      required: ["customerId", "status", "createdAt"],
      properties: {
        customerId: { bsonType: "objectId" },
        status: { enum: ["pending", "paid", "cancelled"] },
        createdAt: { bsonType: "date" }
      }
    }
  }
})

Validation enforces selected structure; it does not establish real-world correctness. Version schema changes, decide how old documents are handled, and test application/driver compatibility.

Use CRUD and indexes deliberately

Use supported drivers, bounded queries, projections, and explicit sort order. Design indexes from measured query shapes; every index consumes storage and adds write work. Inspect query plans and production-like distributions. Unique indexes enforce only their defined key semantics and require careful handling of null/missing values and collation.

Understand consistency and transactions

Read concern, write concern, read preference, replication, and retryable operations influence durability and visibility. Multi-document transactions provide atomicity for supported operations but add cost and do not repair a poor model. Set explicit requirements and test failover, retry, duplicate delivery, and ambiguity after timeouts.

Secure and operate

Enable authentication and authorization, least privilege, TLS, network restrictions, secret management, encryption and key controls, logging, patching, backups, and restore tests. Do not expose a default database listener publicly. Monitor latency, connections, replication lag, storage, indexes, slow queries, capacity, and backup outcomes.

Improve source quality with data cleaning best practices, control permissions through data access governance, and observe pipelines using data pipeline monitoring tools.