MongoDB for Beginners Hero
MongoDB NoSQL Database ⏱ Read time • calculating…

MongoDB for Beginners – Simple NoSQL Guide

Author Avatar
By: Sajid A. Rabby
🗓️ Nov 16, 2025 • 0 words

📘 Who Is This MongoDB Guide For?

This guide is for you if you’ve heard the word “MongoDB” many times, but still feel it’s a bit “foggy” in your head. Maybe you are:

In this article, we’ll go through MongoDB step-by-step in a friendly, practical way. If you read it carefully, you’ll understand the core concepts and feel comfortable enough to start building a small project.

1️⃣ What Is MongoDB in Simple Words?

Short answer: MongoDB is a NoSQL document database. Instead of storing data in tables and rows like SQL databases, MongoDB stores data in documents that look very similar to JSON objects.

Example of one MongoDB document:

{
  _id: ObjectId("673844..."),
  name: "Ali Khan",
  role: "IT Support Engineer",
  skills: ["Windows", "Networking", "MDM"],
  active: true,
  profile: {
    city: "Dammam",
    country: "Saudi Arabia"
  }
}

Instead of thinking in tables and joins, you think in collections and documents. A collection is like a table, and a document is like a row – but more flexible.

If you are comfortable with JSON, you are already close to understanding MongoDB. MongoDB basically stores JSON-like data (technically BSON) in the database.

2️⃣ SQL vs MongoDB – Quick Mental Model

Here is a simple way to map your SQL knowledge to MongoDB:

In SQL, you must define a fixed schema first (columns, data types). In MongoDB, documents in the same collection can have slightly different structures (MongoDB is schema flexible).

3️⃣ Core Building Blocks of MongoDB

🔹 Database

A database is a logical container in MongoDB that holds collections. You can create multiple databases, for example:

🔹 Collection

A collection is like a table in SQL, but without a fixed schema. Example collections:

🔹 Document

A document is a JSON-like object stored inside a collection. Each document has a unique _id field.

Example ticket document in an IT Support system:

{
  _id: ObjectId("6738a5..."),
  title: "User cannot print to network printer",
  priority: "High",
  status: "Open",
  createdAt: ISODate("2025-11-16T10:25:00Z"),
  requester: {
    name: "Mohammed",
    department: "Accounts"
  },
  tags: ["printer", "network", "branch1"]
}

🔹 BSON

Internally, MongoDB stores data in BSON (Binary JSON). You don’t have to worry too much about this – you still read and write JSON-style data, but BSON allows extra types like Date, ObjectId, etc.

4️⃣ When Is MongoDB a Good Choice?

MongoDB shines in scenarios like:

Typical reasons teams choose MongoDB:

5️⃣ Getting Started – How to Use MongoDB (Step by Step)

Step 1 – Choose Where to Run MongoDB

You have two main options:

Practical tip: If your goal is learning full stack (Node + React), start with MongoDB Atlas. It saves you from local install issues and gives you a URL to use directly in your app.

Step 2 – Use a GUI: MongoDB Compass

MongoDB offers a free GUI tool called Compass. It allows you to:

Step 3 – Connect to the Database

In Atlas, you’ll get a connection string like:

mongodb+srv://username:password@cluster0.abcd123.mongodb.net/

You can use this URL in:

6️⃣ Basic CRUD Operations in MongoDB

CRUD means Create, Read, Update, Delete. We’ll use a simple collection called users.

🔹 Create – insertOne() and insertMany()

Insert a single user:

db.users.insertOne({
  name: "Rabby",
  role: "IT Support Specialist",
  skills: ["Windows", "MDM", "Networking"],
  active: true
});

Insert multiple users:

db.users.insertMany([
  { name: "Sara", role: "Developer", active: true },
  { name: "Omar", role: "Network Engineer", active: false }
]);

🔹 Read – find()

Get all users:

db.users.find();

Get only active users:

db.users.find({ active: true });

Query by a condition (age greater than 25):

db.users.find({ age: { $gt: 25 } });

🔹 Update – updateOne(), updateMany()

Set a user as inactive:

db.users.updateOne(
  { name: "Omar" },
  { $set: { active: false } }
);

Add a new skill to a user:

db.users.updateOne(
  { name: "Rabby" },
  { $push: { skills: "SQL Server" } }
);

🔹 Delete – deleteOne(), deleteMany()

Delete a specific user:

db.users.deleteOne({ name: "Sara" });

Delete all inactive users:

db.users.deleteMany({ active: false });

7️⃣ Embedding vs Referencing (Relationships)

MongoDB does not have classic SQL joins by default, but you can model relationships in two main ways:

Option 1 – Embedding (Nested Documents)

Example: Order with embedded items:

{
  _id: ObjectId("6738..."),
  customerName: "Ali",
  items: [
    { product: "Keyboard", qty: 1, price: 80 },
    { product: "Mouse", qty: 2, price: 40 }
  ],
  total: 160
}

Good for data that is usually read together and not too large.

Option 2 – Referencing (Store IDs)

Example: Store userId in the ticket document:

{
  _id: ObjectId("6738..."),
  title: "VPN not connecting",
  userId: ObjectId("66fa...")
}

Your application then looks up the user in the users collection. This is closer to the SQL way of thinking.

8️⃣ Indexes – Making Queries Fast

Just like in SQL, MongoDB uses indexes to speed up queries. If you frequently search by email, you should create an index on it.

Create an index on email:

db.users.createIndex({ email: 1 });

Without indexes, queries on large collections can become slow. For small projects, you may not feel it, but for bigger apps it’s critical.

9️⃣ Security & Best Practices (Beginner Level)

🔟 How to Practice MongoDB Daily (Simple Routine)

Here’s a simple practical plan you can follow in 20–30 minutes per day:

✅ Final Thoughts – MongoDB as a Tool in Your Stack

MongoDB is not “better” or “worse” than SQL – it’s simply a different tool. When you understand both, you can choose the right one for the right problem.

As a beginner, focus on:

Once you get comfortable, you’ll see why so many modern applications rely on MongoDB to handle flexible, fast-changing data.

Back to Blog