Nodea — logo

MongoDB

MongoDB is a popular document-oriented NoSQL database that stores data in flexible documents rather than the rows and columns of classic tables. Each document is a BSON structure (a binary flavour of JSON), which lets you store nested data with a variable schema within a single collection.

How MongoDB works

Instead of splitting a record across many related tables, MongoDB groups related data into a single document that can be retrieved whole, without costly joins. The key concepts that set it apart from relational databases:

  • Document — a single record in BSON format with key–value pairs, including nested ones.
  • Collection — a set of documents, the equivalent of a table but without an enforced schema.
  • Replica set — a group of servers holding copies of the data for high availability and automatic failover.
  • Sharding — horizontal partitioning of data across many servers, enabling scale beyond a single machine's capacity.

MongoDB in practice

MongoDB is a common choice for projects with dynamic or loosely structured data:

  1. Product catalogues — different categories carry different attributes that a flexible document holds without schema changes.
  2. Real-time applications — logs, events and telemetry written at high frequency.
  3. Big Data systems — sharding spreads huge data volumes across many nodes.
  4. Prototypes and rapid iteration — the schema-less model speeds up early development.

Running MongoDB calls for a server with enough RAM and fast disks — the database leans heavily on its cache, so a capable VPS or dedicated server has a direct impact on query response times.

Powiązane pojęcia

Najczęstsze pytania

When should I choose MongoDB over a relational database?

MongoDB fits data that is variable, nested or evolving quickly — like product catalogues or event logs. Relational databases win where complex transactions and rigid relationships between tables are essential. The choice depends on the nature of your data, not on trends.