What if you could find all your data about a person in one quick step instead of hunting through many places?
Rows vs documents thinking in MongoDB - When to Use Which
Imagine you have a big spreadsheet where each row holds a tiny piece of information about a person, like their name, address, and phone number, but all spread out in different rows. You want to find all details about one person quickly.
Looking through many rows to gather all details about one person is slow and confusing. You might miss some rows or mix up data because everything is separated. It's like searching for puzzle pieces scattered all over the table.
With document thinking, all information about one person is stored together in one place, like a complete folder. This makes it easy and fast to find everything about that person without searching through many rows.
SELECT name FROM people WHERE id=1; SELECT address FROM addresses WHERE person_id=1; SELECT phone FROM phones WHERE person_id=1;
db.people.findOne({ _id: 1 })This way of thinking lets you work with whole sets of related information at once, making your data faster to access and easier to understand.
Think about an online store: instead of storing customer info, orders, and reviews in separate tables, a document stores all these details together, so the store can quickly show everything about a customer in one go.
Rows spread data across many places, making gathering related info slow.
Documents keep related data together, speeding up access and simplifying use.
Choosing the right way to organize data helps your apps run smoother and your work easier.