Introduction to Mongo DB (Week 2 Quiz)|Coursera
Which of the following is true regarding data types in MongoDB?
- You should store money using the NumberDecimal (Decimal128) data type.
- MongoDB has a special data type called ObjectId for uniquely identifying documents.
- MongoDB supports many different data types, but you can’t query documents by type.
- By default MongoDB stores all numbers as doubles.
Which of the following is true regarding sort, skip, and limit?
- You can same time by using the limitAndSkip method which wraps the limit and skip methods.
- Sort accepts two arguments, the sort key and the direction to sort.
- The skip method must come before the limit.
- You can achieve pagination by using skip and limit together.
Which of the following queries will match this movie document:
{
"_id": ObjectId("58c59c6a99d4ee0af9e0c32f"),
"title": "Akrobatisches Potpourri",
"year": 1895,
"imdbId": "tt0000011",
"genre": "Documentary, Short",
"viewerRating": 5.5,
"viewerVotes": 111,
"runtime": 1,
"director": "Max Skladanowsky",
"cast": [
"Grunato"
],
"plot": "Eight circus performers known as the Grunato family perform their famous balancing act."
}
- db.movies.find( {“tomatoes.userReviews”: {“$lte” : 2000}} )
- db.movies.find( {“viewerRating”: {“$in” : [10, 5.5, 103, 200]}} )
- db.movies.find( {“genre”: {“$not” : [“Documentary”, “Short”]}} )
- db.movies.find( {“year”: {“$lt” : 1962}} )
- db.movies.find( {“year”: {“$lt: 2015, “$gte” : 2000}} )
Given a collection with the following documents:
{
"arr": [
{ "a": 1, "b": 1 },
{ "a": 2, "b": 2 }
]
}
{
"arr": [
{ "a": 1, "b": 2 },
]
}
{
"arr": [
{ "a": 2, "b": 1 },
{ "a": 1, "b": 2 }
]
}
And given this query:
collection.find({"arr.a": 1, "arr.b": 2})
Which of the documents in the collection will be returned by the query above?
- Only documents 2 and 3.
- Only document 1.
- All 3 documents.
- None of the documents.
In MongoDB, if we have subdocuments we can …
- …reduce the need for database joins.
- …express queries using the fields of subdocuments.
- …not nest another subdocument inside a subdocument.
- …use the subdocuments to store data without limits.
Which of the following commands inserts one document on comments collection?
- mflix.comments.update_many({ … }, {“$set”: {“updated”: true}})
- mflix.comments.insert_one({ “a”: 1})
- mflix.comments.insert_only_one({ “a”: 1 })
- mflix.comments.remove({ … })
- mflix.comments.insert_one({ “a”: 1 }, false)
Which of the following are update operators?
- $set
- $inc
- $divide
- $push
- $add
Which of the following statements are true regarding deleting documents in MongoDB?
- The remove_many() method lets us delete many documents.
- The delete_one() method lets us delete one document.
- The remove_one() method lets us delete one document.
- The delete_many() method lets us delete many documents.