- MongoDB is a document-oriented NoSQL database used for high-volume data storage. It came into light around the mid-2000s.
- Each database contains collections which in turn contain documents.
- Each document can be different, with a varying number of fields.
- The document structure aligns with how developers construct their classes and objects in their respective programming languages.
- The rows (or documents as called in MongoDB) don’t need to have a schema defined beforehand. Instead, the fields can be created on the fly.
- The data model available within MongoDB allows you to represent hierarchical relationships, to store arrays, and other more complex structures more quickly.
Components
- _id: – This is a field required in every MongoDB document.
- The _id field represents a unique value and is like the document’s primary key.
- If you create a new document without an _id field, MongoDB will automatically create the field.
- Collection: This is a grouping of MongoDB documents.
- It is the equivalent of a table that is created in any other RDMS.
- A collection exists within a single database.
- Cursor: This is a pointer to the result set of a query.
- Clients can iterate through a cursor to retrieve results.
- Database: This is a container for collections like in RDMS wherein it is a container for tables.
- Each database gets its own set of files on the file system.
- Document: A record in a MongoDB collection and in turn, it will consist of field names and values.
- Field: A name-value pair in a document.
- A document has zero or more fields.
- Fields are analogous to columns in relational databases.
Welcome to the MongoDB Documentation
Mongoose v7.4.1: Getting Started
- MongoDB creates new collections when you first store data for the collections.
- By default, a collection does not require its documents to have the same schema.
- A MongoDB view is a read-only queryable object whose contents are defined by an aggregation pipeline on other collections or views.
- MongoDB does not persist the view contents to disk. A view's content is computed on-demand when a client queries the view.
- MongoDB provides two different view types: standard views and on-demand materialized views.
- Standard views are computed when you read the view and are not stored on disk.
- On-demand materialized views are stored on and read from disk.
- MongoDB stores data records as BSON documents.
- BSON is a binary representation of JSON documents, though it contains more data types than JSON.