0% completed
Document-oriented databases are a type of NoSQL database designed to store, retrieve, and manage semi-structured data as documents. Instead of relying on rigid schemas like traditional relational databases, they use a flexible structure where each document is self-contained and can have varying fields. These databases are especially useful for applications where data structures evolve over time.
In this lesson, we will explore how document-oriented databases work, their key features, popular systems, and real-world use cases.
In a document-oriented database, data is stored as documents, typically in formats like JSON or BSON. These documents are grouped into collections, and multiple collections make up a database. Each document has a unique identifier (often called _id
) and can contain various fields, arrays, or nested structures.
The attached diagram provides a clear view of the structure:
For example:
{ "name": "Robin", "age": 21, "country": "Sweden", "phone": "+46732223322" }
{ "name": "Peter", "age": 29, "country": "Sweden", "phone": "+46734568900" }
This flexible structure allows each document to have different fields if needed, unlike rows in relational databases that must follow a strict schema.
MongoDB is one of the most popular document-oriented databases. It stores data in BSON (binary JSON) format and supports powerful querying and indexing.
CouchDB is a document database that emphasizes data replication and synchronization.
Example:
Example:
warranty
and brand
, while clothing items include size
and material
.Example:
Document-oriented databases, like MongoDB and CouchDB, offer flexibility, scalability, and performance advantages for modern applications. By organizing data as self-contained documents, they simplify handling diverse and evolving data structures, making them a go-to solution for dynamic and scalable systems.
.....
.....
.....