MongoDB is the most popular document oriented DB.
History
- Created in 2007
- Company: doubleclick
- All data is stored in JSON-like documents
- which are organized in collections where they can be queried.
Flexible schema
Unlike relational ~DB~ table, predefined schema of a table is not necessary.
- This allows you to evolve yout data rapidly without needing to write complex DB migrattion.
Data frequently needed together is stored together, in same place
This makes read operation extremely fast - because no joins are required.
This also makes DB easier to scale horizontally. Via sharding.
Unlike relational tables, collections are self contained, making them much easier to work in distributed systems.
When you create a new Document in mongo - it is assigned a unique object ID - unique to that collection.
Inside that document (document ~ JSON) you can define multiple fields. Each field can be of a data type.
Query API is used to work with your data in any language.
Query API is used to perform basic read and write operations, as well as to do complex queries and transformations across the database.
Index for fast queries
Secondary indexes can be created to make common queries extremely fast.
Also supports geospatial queries to find all documents near a geographical location.
In addition to queries you can also create data aggregation piplines.
MongoDB is free and can be self hosted.
But fastest way to get started is free tier on - Atlas.
Atlas also launched serverless in Jul 21 - i.e. now benefit of pay per usage.
Atlas has other essential features like
- Triggers: make it easy to run serverless functions when your underlying data changes.