MongoDB
A document-oriented NoSQL database storing flexible, JSON-like records.
CurrentbeginnerBeginner-friendlyGuide only -- no course yet
Overview
MongoDB stores data as flexible, JSON-like documents rather than rows in fixed-schema tables, trading some of relational SQL's structure and join capability for schema flexibility -- useful when a data model varies significantly between records or evolves quickly.
- What it is
- A document-oriented NoSQL database storing data as BSON (binary JSON) documents.
- Why it's used
- For flexible or rapidly evolving data models, or data that's naturally document-shaped (nested, variable fields) rather than tabular.
- Where it fits
- An alternative to a relational database when the data model doesn't fit neatly into fixed tables and relationships.
Core concepts
- Documents and collections
- BSON/JSON-like structure
- Querying with a query object, not SQL
- Indexes
Example
Documents can have nested arrays/objects (tags here) without a fixed schema -- unlike a SQL table, two documents in the same collection can have different fields.
db.books.insertOne({ title: "Example", price: 12.99, tags: ["fiction"] });
db.books.find({ price: { $lt: 15 } });Common use cases
- Content management systems with varying content shapes
- Rapidly-prototyped applications
- Catalogs with variable per-item attributes
Project ideas
- Model the same bookstore data as SQL tables versus MongoDB documents, and compare how each handles a book with optional/variable fields