Document Databases in NoSQL

Last Updated : 25 Jun, 2026

The Document Database Model is a type of NoSQL database model that stores data in the form of documents instead of rows and columns. Documents are usually stored in formats such as JSON, BSON or XML, making them flexible and easy to manage.

  • Data is stored as documents rather than rows and tables.
  • Supports flexible and dynamic schemas.
  • Documents can contain nested data and complex structures.
  • Designed for high scalability and fast data retrieval.

Components of a Document Data Model

A Document Data Model consists of components that store and organize data as documents, enabling flexible and hierarchical data management.

Document

A document is the basic unit of data storage. It contains related information organized as key-value pairs.

Example:

{
"_id": 101,
"name": "John",
"age": 25,
"city": "Delhi"
}

Fields

Fields are individual attributes within a document. Each field consists of a field name and a corresponding value.

Example:

FieldValue
nameJohn
age25
cityDelhi

Collection

A collection is a group of related documents. It is similar to a table in a relational database but does not require a fixed schema.

Example:

Users Collection

[
{
"_id": 101,
"name": "John",
"age": 25
},
{
"_id": 102,
"name": "Alice",
"age": 30
}
]

Embedded Documents

A document can contain another document within it, allowing related data to be stored together.

Example:

{
"_id": 101,
"name": "John",
"address": {
"city": "Delhi",
"pincode": 110001
}
}

Working of Document Database Model

A Document Database Model stores data as documents within collections, enabling flexible storage and retrieval of semi-structured data.

Step 1: Store Data as Documents

Instead of storing data in rows, a document database stores information in individual documents.

Example:

{
"StudentID": 101,
"Name": "David",
"Branch": "Computer",
"Age": 20
}

Step 2: Group Documents into Collections

Similar documents are stored together in a collection.

Students Collection:

{
"StudentID": 101,
"Name": "David",
"Branch": "Computer"
}

{
"StudentID": 102,
"Name": "Alen",
"Branch": "Electronics"
}

Step 3: Insert Data

New documents can be added without modifying the existing structure of the collection.

Step 4: Retrieve Data

The database searches and retrieves documents directly based on fields such as StudentID, Name or Branch.

Step 5: Scale Across Servers

Document databases can distribute collections across multiple servers to handle large volumes of data efficiently.

Example of a Document Database in NoSQL

The following example illustrates an employee document stored in a NoSQL database.

Employee Document (JSON Format):

{
"employee_id": 101,
"name": "John Smith",
"department": "IT",
"email": "john.smith@example.com",
"address": {
"city": "New York",
"country": "USA"
},
"projects": [
{
"project_id": 1,
"project_name": "Website Development"
},
{
"project_id": 2,
"project_name": "Mobile App"
}
]
}
  • Data is stored as a document.
  • Employee details, address and projects are stored together.
  • Flexible schema allows adding new fields easily.
  • All related data can be retrieved with a single query.
  • MongoDB
  • CouchDB
  • Amazon DocumentDB
  • Azure Cosmos DB

Advantages of Document Database Model

  • Flexible Schema: Documents can have different fields and structures without affecting other documents.
  • Easy Data Representation: Complex and nested data can be stored naturally within a single document.
  • High Scalability: Data can be distributed across multiple servers to support large-scale applications.
  • Fast Data Access: Documents can be retrieved quickly without requiring complex joins.
  • Developer Friendly: JSON-like document formats are easy to understand and work with in modern applications.

Limitations of Document Database Model

  • Data Redundancy: Similar information may be repeated across multiple documents, increasing storage usage.
  • Complex Relationships: Managing relationships between documents can be more difficult than in relational databases.
  • Limited Join Support: Most document databases provide limited or less efficient join operations.
Comment