🍃 What is MongoDB? MongoDB is a NoSQL document-based database that stores data in JSON-like format. Instead of rows and columns, it uses collections and documents . This makes it super flexible and schema-less — perfect for fast-moving modern apps 🚀. 💡 Difference vs SQL Databases: SQL = Tables, Rows, Columns 📊 MongoDB = Collections, Documents 📚 ❓Why Indexes Matter Imagine searching a phonebook without alphabetical order — painful, right? 😅 Indexes make your searches faster by letting MongoDB skip scanning every document. ⚡ Tip: Without indexes, MongoDB performs a collection scan — meaning it checks every record. That’s fine for 10 docs... not for 10 million! 🧠 Types of Indexes in MongoDB 1️⃣ Single Field Index Most basic and common. You index one field. db.users.createIndex({ "name": 1 }) 1 = ascending , -1 = descending . Used for queries like { name: "Priya" } . 2️⃣ Compound Index Multiple fields combined to improve multi-fi...
A cozy space where I share my daily Java learnings, issues, and solutions.