Introduction to MongoDB

Subject:  MongoDB

Topic: Introduction to MongoDB

Difficulty Level: Easy

No. of Questions: 10

1. Which of the following is true about MongoDB?

a) MongoDB is a relational database

b) MongoDB is a NoSQL database

c) MongoDB is an object-oriented database

d) MongoDB is a graph database

View Answer

Answer: b) MongoDB is a NoSQL database

Answer Explanation: MongoDB is a NoSQL database, which means it does not use the traditional SQL-based relational model for storing data.

2. Which of the following is NOT a characteristic of MongoDB?

a) High scalability

b) Flexible data model

c) Consistency in data replication

d) High availability

View Answer

Answer: c) Consistency in data replication

Answer Explanation: MongoDB provides eventual consistency, which means that updates to the database may take some time to propagate to all nodes in a distributed cluster.

3. Which data format is used by MongoDB?

a) XML

b) JSON

c) YAML

d) CSV

View Answer

Answer: b) JSON

Answer Explanation: MongoDB uses JSON (JavaScript Object Notation) as its primary data format.

4. Which of the following is NOT a benefit of using MongoDB?

a) High performance

b) Schemaless data model

c) Flexible queries

d) Data integrity and constraints

View Answer

Answer: d) Data integrity and constraints

Answer Explanation: MongoDB does not provide built-in data integrity and constraints, as it is designed for flexible and schemaless data storage.

5. What is a “document” in MongoDB?

a) A table in a relational database

b) A collection of related fields

c) A unit of data in a NoSQL database

d) A query language used to retrieve data

View Answer

Answer: c) A unit of data in a NoSQL database

Answer Explanation: In MongoDB, a document is a unit of data storage, similar to a row in a relational database.

6. Which of the following is a valid data type in MongoDB?

a) Boolean

b) Double

c) String

d) All of the above

View Answer

Answer: d) All of the above

Answer Explanation: MongoDB supports a variety of data types, including Boolean, Double, and String.

7. What is the role of a “collection” in MongoDB?

a) It defines the structure of a document

b) It is a group of related documents

c) It provides a schema for the database

d) It is a type of index used for querying data

View Answer

Answer: b) It is a group of related documents

Answer Explanation: In MongoDB, a collection is a group of related documents that are stored together. Collections are analogous to tables in a relational database.

8. Which of the following is NOT a type of index supported by MongoDB?

a) Single-field index

b) Compound index

c) Multikey index

d) Hierarchical index

View Answer

Answer: d) Hierarchical index

Answer Explanation: While MongoDB supports single-field, compound, and multikey indexes, it does not support hierarchical indexes.

9. What is a “shard” in MongoDB?

a) A type of data model used for hierarchical data

b) A subset of a MongoDB database

c) A distributed cluster of MongoDB nodes

d) A type of query used for joining data

View Answer

Answer: c) A distributed cluster of MongoDB nodes

Answer Explanation: A shard in MongoDB is a distributed cluster of nodes that collectively store a subset of the data in a database. Sharding is used for horizontal scaling of data storage and processing.

10. What is the default write concern in MongoDB?

a) 1

b) 0

c) majority

d) all

View Answer

Answer: a) 1

Answer Explanation: The default write concern in MongoDB is “1”, which means that the write operation must be acknowledged by at least one node before it is considered successful.

This topic covers the basics of MongoDB, including its definition, features, and architecture.