MongoDB Questions and Answers Part-21

1. Point out the correct statement.
a) ObjectIds are small, likely unique, fast to generate, and ordered
b) ObjectIds are large, likely unique, and ordered
c) ObjectIds values consists of 18-byte
d) All of the mentioned

Answer: a
Explanation: In MongoDB, documents stored in a collection require a unique _id field that acts as a primary key.

2. Which of the following data type is depreciated?
a) Double
b) String
c) Object
d) Undefined

Answer: d
Explanation: MongoDB treats some types as an equivalent for comparison purposes.

3. Each data type has a corresponding number that can be used with the _______ operator to query documents by BSON type.
a) $type
b) $server
c) $agent
d) None of the mentioned

Answer: a
Explanation: $type selects the documents where the value of the field is an instance of the specified numeric BSON type.

4. Point out the wrong statement.
a) BSON Date is a 32-bit integer that represents the number of milliseconds
b) The BSON timestamp type is for internal MongoDB use
c) If you need to query the database for exact, mathematically valid matches, use Ambiguity Precision
d) None of the mentioned

Answer: a
Explanation: This results in a representable date range of about 290 million years into the past and future.

5. There is _________ byte counter in BSON, starting with a random value.
a) 2
b) 3
c) 4
d) None of the mentioned

Answer: b
Explanation: ObjectId is a 12-byte BSON type

6. In the mongo shell, you can access the creation time of the ObjectId, using the ______ method.
a) getTime()
b) getTimestamp()
c) Timestamp()
d) None of the mentioned

Answer: b
Explanation: MongoDB clients should add an _id field with a unique ObjectId.

7. The __________ JavaScript shell and the MongoDB language drivers translate between BSON and the language-specific document representation.
a) mongod
b) mongo
c) iscript
d) none of the mentioned

Answer: b
Explanation: The value of a field can be any of the BSON data types.

8. Point out the correct statement.
a) MongoDB stores chunks on disk in the XML serialization format
b) MongoDB stores documents on disk in the BSON serialization format
c) MongoDB stores documents on RAM in the JSON serialization format
d) All of the mentioned

Answer: a
Explanation: BSON documents may have more than one field with the same name.

9. BSON is a binary representation of ________ documents.
a) JSON
b) XML
c) JScript
d) All of the mentioned

Answer: a
Explanation: BSON contains more data types than JSON.

10. MongoDB documents are composed of field-and-value pairs and have the following structure?
a) field1:; value1
b) field1: value1;
c) field1: value1
d) none of the mentioned

Answer: c
Explanation: The value of a field can be any of the BSON data types, including other documents, arrays, and arrays of documents.