I have a question. Why is everyone in tech obsessed with abstraction?
Almost everything is an abstraction over some complex or repetitive task.
Some abstractions remove repetitive tasks, while others hide complexity and provide simpler ways to do that work.
But this abstraction comes with some cost. We'll discuss that cost some other day.
MongoDB is also an abstraction that provides a simpler way to store and work with data.
And this abstraction starts with its core concept: documents.
What does that mean? Don't be confused.
It means you can store user data in one document, product data in another document, and if you need to store other details, like orders, you can store them in separate documents.
You don't need to worry about how MongoDB stores this data at the physical or low level. MongoDB manages how the data is stored internally. This gives you the document abstraction.
Now, the second main abstraction is tables and relationships.
Think in terms of a relational database. Assume you need to store details of a user, like their address. What would you do?
Ummmmmmm 🤔🤔
We first create a user table and then connect it with an address table.
Here, we need to manually define relationships between these tables.
But MongoDB allows you to store this information in one document.
One disclaimer: neither model is perfect. It depends on the use case.
This gives you an abstraction over managing relationships between data.
Now, the next abstraction MongoDB provides is operations.
We can query documents and collections to retrieve useful information.
Using commands, you tell MongoDB what you want to find or change. Now, MongoDB determines how to execute that operation using its query engine, indexes, and storage mechanisms.
And that's how MongoDB makes working with data simpler through abstraction.
Top comments (0)