Skills Test Answers - MongoDB

In what language(s) is MongoDB supported?

Python
Javascript
PHP
All of above.
Perl



True or False? MongoDB can have foreign keys.

False
True



Which of the following expressions are valid JSON documents?

{Name: "Schoolify", url: 'www.schoolifybd.com'}
{Name: Schoolify, url: 'www.schoolifybd.com'}
{Name: "Schoolify": url: 'www.schoolifybd.com'}
{Name: "Schoolify". url: 'www.schoolifybd.com'}
{Name: "Schoolify", url: www.schoolifybd.com}



Which of the following are considered Core MongoDB operations?

Create, Select, Update, Drop
Create, Read, Update, Drop
Create, Read, Update, Delete
Create, Select, Update, Delete



MongoDB's query language uses operators that start with which character?

@
$
#
:



You can write custom MapReduce functions in MongoDB using:

Json
Python
Java
Javascript
PHP



Which of the following would you use to query an inventory collection to get all items of type "food" with price less than $34?

db.inventory.find({type: "food", price: {$lt: 34}}).explain()
db.inventory.find({type: "food", price: {$lt: 34}})
db.inventory.find({type: "food", price: {$lte: 34}})



The interactive "mongo" shell interface is based on:

JavaScript
Python
Ruby
Scala



Which of the following is syntactically correct for searching the "posts" collection for a post with the title of "Big News Story"?

db.posts.find(title: 'Big News Story');
posts.search('title': 'Big News Story');
posts.search({'title': 'Big News Story'});
db.posts.find({title: 'Big News Story'});



How can you optimize document storage?

Specify an explicit, smaller _id value
Use shorter field names within documents
Embed small documents within other documents
(All of these)



This replication process is

synchronous
asynchronous



Which of the following terms describe MongoDB?

Document-oriented DBMS
Static schema
Configurable cache
Relational database



Instead of tables, MongoDB stores data in structures called:

Collections
Pages
Maps
Tuples



What does MongoDB's Sharding provide?

Automatic balancing for changes in load and data distribution
Automatic failover
Easy addition of new machines without down time
Scaling to one thousand nodes
All of these



Which of the following statement are true

The _id of a document need only be unique on the shard in which the document is housed
By default, there is no index on _id. It is best practice to add one if you expect to query based on _id.
If you do not specify and _id when doing an insert, the driver will create one for you
You must specify and _id when inserting documents



The maximum BSON document size is:

8 megabytes
4 megabytes
16 megabytes
12 megabytes



MongoDB supports UTF-8 for strings in stored objects and queries:

Sometimes
Never
Always



Which of the following statements are true about MongoDB

MongoDB supports joins
MongoDB does not support transactions and operations are not atomic.
MongoDB does not support transactions but operations are atomic.
MongoDB supports transactions



Which platform does MongoDB support?

Mac OS X
Windows
Linux
All of above



The MongoDB database is capable of:

ACID-compliant transactions
Multi-table joins
Atomic (per document) operations
Multi-object commits with rollbacks



MongoDB stores documents in structures called

BSON objects
JSON objects
JavaScript objects
ODB objects



Which method should be used to create an index on a collection, if it does not already exist?

ensureIndex()
createIndex()
reIndex()
checkIndex()



To perform a search on a collection, and obtain a cursor object for the results, use:

query()
findAndModify()
find()
findOne()



The map-reduce operation uses a temporary collection for data processing; The benefit of this behavior is that the operations:

Do not take up any additional space in the database
Are more secure than they would be if performed on a named collection
Can be performed concurrently on the same collection, without affecting the intermediate states
Are more accurate than they would be if performed on the live data



Which statement of the followings could NOT drop an index?

db.runCommand({dropIndexes:'foo', index : '*'})
db.runCommand({dropIndexes:'foo', index : {y:1}})
db.myCollection.reIndex()
db.collection.dropIndex({x: 1, y: -1})
db.collection.dropIndexes();



To create an index for user_name field on user collection, which of the following is the correct syntax?

db.user.ensureIndex({user_name:1});
db.user.createIndex({user_name:1});
db.user.saveIndex({user_name:1});
db.user.attachIndex({user_name:1});



The currently preferred replication method is called:

Replica pairs
Master/Slave
Arbiter members
Replica sets



TSV files should be expected to contain:

Document indexing for a named Collection
Binary data logs
Tab-separated text fields
Geographic data coordinates



To atomically modify and return a single document from a collection, use:

upsert()
aggregate()
findAndModify()
update()



Indexes in mongodb are NOT good for:

Collections where the number of reads is much greater than the number of writes.
Collections which are write-intensive



Which feature of mongoDB is used to balance load among multiple machines?

GridFS
Sharding
Replica Sets
Geospatial Indexing
BSON



MongoDB uses GridFS to:

Store large files, distributed as smaller pieces
Prevent data loss after a crash or hard shutdown
Reduce and summarize large data structures
Index and sort extremely large sets of documents



The core database operations in MongoDB are abbreviated as:

BSON
JSON
CRUD
MDB



In MongoDB V2.4, what type of JavaScript engine is used to execute all JavaScript on Mongo shell ?

Rhino
SpiderMonkey
JavaScriptCore
Futhark
V8



The aggregation framework is most similar to which facility from the world of relational databases

views
foreign keys
Group by
constraints



The binary log of transactions used to recover the database after a crash is called the:

Journal
Master Replica
Primary Shard
Ledger



When Storing large files in MongoDB one is encouraged to use...

GridFS
BSON
MongoFS
None of these



Authentication in MongoDB is:

Available with sharding since version 1.8.
Off by default.
U udp firewall between mongod and client connections.
Based on Linux user authentication.
Not needed if we use a non-standard port for mongod.



MongoDB's Replication can be in Master-Slave form or _______ form.

Replica Sets
None of above
Replications
Sharding



Which of the following is not a stage in the aggregation pipeline

sort
group
having
limit



Which of the following atomic operations would you use to add a value to an array only if it does not already exist in the array?

$inc
$pop
$push
$addToSet
$pull



While replication provides data redundancy, journaling is also recommended because:

It allows the use of Replica Sets in addition to Replica Pairs
It improves write performance on the journaled database
It allows faster, more reliable recovery after a crash
It improves read performance on the journaled database



Which feature of mongoDB is used for data redundancy?

GridFS
Embedded Documents
Sharding
BSON
Replica Sets



MongoDB can have indexes on Array Elements?

False
True, MongoDB indexes the first non-empty element of the array.
True, MongoDB indexes the first element of the array.
True, MongoDB indexes each element of the array.



What's the difference between `save()` and `insert()` in mongo shell?

No difference between them.
save() updates the document if if already exists (judges by comparing them byte by byte); inserts if it's new.
save() updates the document if if already exists (judges by their indexed keys); inserts if it's new.
save() updates the document if if already exists (judges by if they already contains `_id`); inserts if it's new.
None of above is correct.



MongoDB uses the acronym TTL to mean:

Table Time Limit
Temporary Table Listing
Time To Live
Total Time Limit



Indexing

Makes all writes faster
Makes writes that involve the index faster
Slows down reads that involve the index
Slows down writes that involve the index



An operation is said to be "idempotent" if it is proven to:

Eventually produce consistent results, if run a sufficient number of times with the same inputs
Produce varying results when run multiple times, even with the same input
Produces results within linear time, compared to the number of inputs
Produce consistent results over multiple runs, given the same input



Which of the following binaries handles routing of sharded queries to the proper shard?

mongo
mongorouter
mongos
mongod



MongoDB document names cannot start with the characters:

@ or #
( or )
$ or .
^ or *



What do drivers use with protocol on the wire?

Protocol Buffers
BSON
REST
JSON



Due to their default behavior, Capped Collections are ideal for storing:

Non-vital, chronological records, like logs
Important records like user accounts or invoices
Records that require high levels of consistency, e.g. account balances or sales figures
Extremely large, unordered lists of documents



When a Capped Collection becomes full, and a new document is added:

The collection expands, based on size_increment property, only if auto_resize is enabled
The oldest entry is overwritten with the new document
The newest stored entry is overwritten by the new document
The operation fails



What is the extra space allocated to document on the disk to prevent moving a document when it grows as the result of update() operations.

map-reduce
pcap
padding
partition



A Priority 0 or "passive" replica member:

Does not vote in elections during a failover
Does not accept read operations
Does not maintain a full copy of the data set
Cannot become a primary member



"write concern" allows an application to:

Ensure that data storage is evenly distributed between servers
Track the amount of space remaining after each database write
Observe the success or failure of database writes
Create event handlers that fire in response to database writes



"read preference" affects how an application:

Selects a replica set member to read from
Selects the index to use when searching for a document
Selects a document collection for a read operation
Sorts the results of a read operation



All writes in MongoDB Must go the primary

False
True by default but can be overridden
True
False by default but can be overriden



If you have a compound index on multiple fields (a,b,c), you can use it to query on:

(a), (a,b), or (a,b,c)
Any combination of a,b,c
(a), (b), or (c)
Only (a,b,c)



The equivalent for like %keyword% on mongodb find is:

db.collection.find({field:{$regex:{/keyword/},$options:"i"})
db.collection.find({field:"/keyword/i")
db.collection.find({field:{$regex:{/keyword/i}})



How many collections are created when use use gridfs to store large files

2
1
3
0



What is the easiest way to do tasks like totaling or averaging field values in MongoDB newer versions?

Use Map-Reduce
Use Aggregation Framework
Use newly-implemented $avg and $total collection operations.



You want to minus one to field foo, what should you use?

{ foo : { $inc : -1 } }
{ $inc : { foo : -1 } }
{ foo : { $dec : 1 } }
{ $dec : { foo : 1 } }



Which of the following statements are true about the MongoDB Write Consistency model

Eventually consistent by default
Depends on the value of w parameter specified in the getLastError cal.
Always strongly consistent
Strongly consistent by default, can be made eventually consistent



Which of the following is the correct operation to query a document for both 'Football' and "Reading" within the interests data collected from a profile?

db.profile.find({interests: "Football", interests: "Reading"})
db.profile.find({interests: {$all : ["Football", "Reading"] }})
db.profile.find({interests: {$in: ["Football", "Reading"] }})
db.profile.find({$or: [{interests: "Football"}, {interests: "Reading"}]})



How many data types are available in MongoDB?

6
2
8
4



When a replica set election takes place which types of nodes can participate

regular, hidden, and arbiters
only arbiters
only regular nodes
regular and arbiters but not hidden



Which datum does MongoDB use for calculating geospatial coordinates?

LVM
TSV
GPS
WGS84



What term is use to describe the order that a database stores documents on disk?

sort order
natural order
write order
oplog



Which of the following is not a BSON serialization type?

ObjectId
Regular expression
Hash table
Double



In MongoDB's Geospatial Indexing, if you want to create & use index on EARTH, what is NOT TRUE?

Using decimal degrees in (longitude, latitude) order.
Indexing documents by multiple locations is possible in recent versions.
Adding spherical : true inside geoNear query.
Creating a "2d" index first.
Specifying in key like { lat : -50, lon : 13 }



A property used to address servers based on their real-world locations is called:

GeoIP
Sharding
Cluster tagging
Data-center awareness



You cannot use characters among /\. "*<>:|? in database names, in release version

<=2.0
>=2.2
>=2.0
<=2.2
>=1.8



MongoDB queries return a limited size (or "threshold") of results by default, usually:

101
256
4096
512



What is the minimum number of mongod instances that may make up a replica set?

1
3
4
2



Haystack Indexes are typically used to:

Index large sets of documents for quick keyword searches
Improve the performance of 2D geospatial queries
Improve the performance of spherical coordinate queries
Provide full-text indexing and searches within large, individual documents



Suppose you have a collection foo with an index created using the statement db.foo.ensureIndex({a:1, b:-1, c:1}). Which of the following queries could use the index

db.foo.find({c:1})
db.foo.find({b:1})
db.foo.find({a:1, b:1})
db.foo.find({c:1, b:1})



By default, MongoDB allows up to _____ collections.

32,768
12,000
Unlimited
65,536
24,000