The document provides an overview of MongoDB, a NoSQL database that uses JSON-like BSON documents, highlighting its key features such as schema-less design, scalability, and high performance. It includes common interview questions and answers regarding database creation, data manipulation, indexing, and security practices. Additionally, it explains the differences between MongoDB and MySQL, as well as how MongoDB handles relationships and large-scale applications.
The document provides an overview of MongoDB, a NoSQL database that uses JSON-like BSON documents, highlighting its key features such as schema-less design, scalability, and high performance. It includes common interview questions and answers regarding database creation, data manipulation, indexing, and security practices. Additionally, it explains the differences between MongoDB and MySQL, as well as how MongoDB handles relationships and large-scale applications.
MongoDB is a NoSQL database that stores data in JSON-like BSON documents instead of tables. It is schema-less, highly scalable, and optimized for high-speed data retrieval.
What are the key features of MongoDB?
Schema-less, Document-Oriented, Scalability with Sharding, High Performance with Indexing.
How does MongoDB differ from MySQL?
MongoDB is NoSQL (document-based), while MySQL is relational (table-based). MongoDB is schema-less and scalable horizontally, while MySQL uses structured schema and scales vertically.
How do you create a database in MongoDB?
use myDatabase (Creates a new database when a collection is added).
What is indexing in MongoDB, and why is it important?
Indexing improves query speed by allowing faster data retrieval. Example: db.users.createIndex({ email: 1 })
What types of indexes are available in MongoDB?
Single Field Index, Compound Index, Text Index, Geospatial Index.
How do you optimize queries in MongoDB?
Use indexes, avoid unnecessary find() queries, use projection, and leverage the aggregation framework. What is the aggregation framework in MongoDB? Aggregation is used to process and transform data in multiple stages, similar to SQL's GROUP BY.
How does MongoDB handle relationships between documents?
MongoDB uses Embedding (stores related data inside a document) and Referencing (stores references to related documents).
What is the difference between embedding and referencing in MongoDB?
Embedding stores all data in one document, making reads faster. Referencing uses separate documents linked by ObjectId, saving space.
How do you secure MongoDB databases?
Enable authentication, use TLS/SSL encryption, and limit user privileges with roles.
How do you back up a MongoDB database?
Use the mongodump command: mongodump --db myDatabase --out /backup/
How does MongoDB handle large-scale applications?
MongoDB uses sharding to distribute data across multiple servers and replication for data redundancy.
Why did you choose MongoDB for backend development?
MongoDB is flexible, scalable, and efficient for handling large datasets. It supports fast reads and writes, making it ideal for modern web applications.
Immediate download Nuclear Power Plants Innovative Technologies for Instrumentation and Control Systems The Second International Symposium on Software Reliability Industrial Safety Cyber Security and Physical Protection of Nuclear Power Plant 1st Edition Yang Xu ebooks 2024