MongoDB MCQs – Advanced Features

11.) Which command is used to create a Time-series Collection in MongoDB?

A) db.createTSCollection()
B) db.createTimeSeries()
C) db.createTS()
D) db.createCollection()

Answer: Option D

Explanation: The db.createCollection() command is used to create a Time-series Collection with the timeseries option.

12.) Which command is used to retrieve a file from GridFS?

A) fs.chunks.retrieve()
B) gridfs.retrieve()
C) fs.files.retrieve()
D) mongofiles

Answer: Option D

Explanation: The mongofiles command is used to retrieve a file from GridFS.

13.) Which of the following is true about Change Streams?

A) They can monitor changes to a single collection
B) They can monitor changes to an entire database
C) They can monitor changes to a replica set
D) All of the above

Answer: Option D

Explanation: Change Streams can monitor changes to a single collection, an entire database, or a replica set.

14.) What is the purpose of the fs.files collection in GridFS?

A) To store metadata about files
B) To store the actual file data
C) To compress files
D) To encrypt files

Answer: Option A

Explanation: The fs.files collection stores metadata about files in GridFS.

15.) Which of the following is true about MongoDB Transactions?

A) They are atomic at the single-document level
B) They are atomic at the multi-document level
C) They are not atomic
D) They are used for compressing data

Answer: Option B

Explanation: MongoDB Transactions are atomic at the multi-document level.

16.) What is the purpose of the fs.chunks collection in GridFS?

A) To store metadata about files
B) To compress files
C) To store the actual file data
D) To encrypt files

Answer: Option C

Explanation: The fs.chunks collection stores the actual file data in GridFS.

17.) Which of the following is true about Time-series Collections?

A) They automatically expire data after a certain period
B) They are not optimized for time-series data
C) They are used for encrypting data
D) They are used for compressing data

Answer: Option A

Explanation: Time-series Collections can automatically expire data after a certain period using the expireAfterSeconds option.

18.) Which command is used to insert a file into GridFS?

A) fs.chunks.insert()
B) gridfs.insert()
C) fs.files.insert()
D) mongofiles

Answer: Option D

Explanation: The mongofiles command is used to insert a file into GridFS.

19.) What is the purpose of the withTransaction() method in MongoDB?

A) To compress data
B) To execute a transaction
C) To encrypt data
D) To back up data

Answer: Option B

Explanation: The withTransaction() method is used to execute a transaction.

20.) Which of the following is true about GridFS?

A) It stores files in two collections: fs.files and fs.chunks
B) It compresses files
C) It encrypts files
D) It backs up files

Answer: Option A

Explanation: GridFS stores files in two collections: fs.files (metadata) and fs.chunks (file data).

Leave a Reply

Your email address will not be published. Required fields are marked *