Mongo
Work through every question currently mapped to this canonical topic.
- What are the advantages of MongoDB? Or in other words, why choosing MongoDB and not other implementation of NoSQL?
Answer
MongoDB advantages are as following:
- Schemaless
- Easy to scale-out
- No complex joins
- Structure of a single object is clear
- What is the difference between SQL and NoSQL?
Answer
The main difference is that SQL databases are structured (data is stored in the form of tables with rows and columns - like an excel spreadsheet table) while NoSQL is unstructured, and the data storage can vary depending on how the NoSQL DB is set up, such as key-value pair, document-oriented, etc.
- In what scenarios would you prefer to use NoSQL/Mongo over SQL?
Answer
- Heterogeneous data which changes often
- Data consistency and integrity is not top priority
- Best if the database needs to scale rapidly
- Heterogeneous data which changes often
- What is a document? What is a collection?
Answer
- A document is a record in MongoDB, which is stored in BSON (Binary JSON) format and is the basic unit of data in MongoDB.
- A collection is a group of related documents stored in a single database in MongoDB.
- A document is a record in MongoDB, which is stored in BSON (Binary JSON) format and is the basic unit of data in MongoDB.
- What is an aggregator?
Answer
- An aggregator is a framework in MongoDB that performs operations on a set of data to return a single computed result.
- What is better? Embedded documents or referenced?
Answer
- There is no definitive answer to which is better, it depends on the specific use case and requirements. Some explanations : Embedded documents provide atomic updates, while referenced documents allow for better normalization.
- Have you performed data retrieval optimizations in Mongo? If not, can you think about ways to optimize a slow data retrieval?
Answer
- Some ways to optimize data retrieval in MongoDB are: indexing, proper schema design, query optimization and database load balancing.
- Explain this query: db.books.find({"name": /abc/})
🚧 Answer not written yet.
- Explain this query: db.books.find().sort({x:1})
🚧 Answer not written yet.
- What is the difference between find() and find_one()?
Answer
find()returns all documents that match the query conditions.- find_one() returns only one document that matches the query conditions (or null if no match is found).
- How can you export data from Mongo DB?
Answer
- mongoexport
- programming languages