0PricingLogin
MongoDB Academy · Lesson

Databases, Collections, and Namespaces

Learners will create a database, add collections, and understand how MongoDB organises data at the namespace level.

MongoDB's Three-Level Hierarchy

MongoDB nests data in three levels: Database, Collection, Document. It mirrors SQL's database, table, row — and one server can hold many of each.

What Is a Namespace?

A namespace names a collection by combining database and collection with a dot, like myapp.users. You'll see this notation in logs and explain output.

// Namespace: database.collection
// 'shop' database, 'products' collection:
use shop
db.products.find({})
// MongoDB internally refers to this as 'shop.products'

// You can also reference it explicitly:
db.getSiblingDB('shop').getCollection('products').find({})

All lessons in this course

  1. What Is a BSON Document?
  2. Collections vs SQL Tables
  3. Databases, Collections, and Namespaces
  4. The mongosh Shell Essentials
← Back to MongoDB Academy