Mongodb

Which command adds members to the replica set from MongoDB shell?

1.

`rs.add("<hostname>")`

2.

`replicaSetAdd("<hostname>")`

3.

`rs.insert("<hostname>")`

4.

`replica.add("<hostname>")`

Q 1 / 76

Mongodb

Which MongoDB shell command should you use to back up a database?

1.

restore

2.

backup

3.

mongobackup

4.

mongodump

Q 2 / 76

Mongodb

Which shell query displays all citizens with an age greater than or equal to 21?

1.

`db.citizens.select('WHERE age >= 21')`

2.

`db.citizens.where('age >= 21')`

3.

`db.citizens.find('WHERE age >= 21')`

4.

`db.citizens.find({age: {$gte: 21}})`

Q 3 / 76

Mongodb

What does a MongoDB collection consist of?

1.

data

2.

documents

3.

fields

4.

rows

Q 4 / 76

Mongodb

Given an ObjectId in `_id`, how do you get the time it was created?

1.

`getDateTime(_id)`

2.

`_id.createDate()`

3.

`_id.getTimestamp()`

4.

`_id.getDateTime()`

Q 5 / 76

Mongodb

Given a cursor named myCursor, which command returns a boolean value?

1.

myCursor.hasNext()

2.

myCursor.sort()

3.

myCursor.next()

4.

myCursor.find()

Q 6 / 76

Mongodb

Which command returns a specific document in the user's collection?

1.

`db.users.find({_id: 1})`

2.

`db.users.seek({_id: 1})`

3.

`db.users.query({_id: 1})`

4.

`db.query.users({_id: 1})`

Q 7 / 76

Mongodb

To import a JSON array into Mongo, what flags are needed with MongoDBimport?

1.

`--type jsonArray`

2.

`--json`

3.

`--type json`

4.

`--jsonArray`

Q 8 / 76

Mongodb

Choose the shell command that connects to a MongoDB database.

1.

mongo

2.

mongod

3.

mongoconnect

4.

dbconnect

Q 9 / 76

Mongodb

In the MongoDB shell, how can you tell if an index was used with a query?

1.

db.customers.find({lastName: 'smith'}).explain()

2.

db.customers.find({lastName: 'smith'}).perf()

3.

db.customers.find({lastName: 'smith'}).plan()

4.

db.customers.find({lastName: 'smith'}).usedIndex()

Q 10 / 76

Mongodb

Suppose your aggregation pipeline terminated with an exception referring to exceeded memory limit. What is the best way to resolve the issue?

1.

Set useMemory to twice amount indicated in exception.

2.

Switch a 64 bit instance of MongoDB.

3.

Increase the memory of the MongoDB server.

4.

Set allowDiskUse to true.

Q 11 / 76

Mongodb

What is the recommended way to delete a user?

1.

db.deleteUser("user")

2.

db.removeUser("user") DEPRECATED

3.

db.remove("user")

4.

db.dropUser("user")

Q 12 / 76

Mongodb

What the primary database in a replica set fails, when does failover begin?

1.

once the primary has been down for 10 minutes

2.

once the primary reboots

3.

immediately

4.

after the administrator reboots the primary

Q 13 / 76

Mongodb

What is the correct option to set up Kerberos when starting MongoDBd?

1.

`--setParameter authenticationMechanisms=GSSAPI`

2.

`--setAuthentication=GSSAPI`

3.

`--setParam auth=K`

4.

`--setAuth method=Kerberos`

Q 14 / 76

Mongodb

What is the purpose of an arbiter in a replica set?

1.

It monitors replica set and sends email in case of failure

2.

It casts the tie-breaking vote in an election.

3.

It holds a backup copy of the database.

4.

It reboots the failed server.

Q 15 / 76

Mongodb

You want to know how many types of items you have in each category. Which query does this?

1.

`db.product.group({_id: "$category", count: {$sum:1}})`

2.

`db.product.aggregate($sum: {_id: "$category", count: {$group:1}})`

3.

`db.product.aggregate($group: {_id: "$category", count: {$sum:1}})`

4.

`db.product.aggregate($count: {_id: "$category", count: {$group:1}})`

Q 16 / 76

Mongodb

To restrict the number of records coming back from a query, which command should you use?

1.

take

2.

limit

3.

max

4.

skip

Q 17 / 76

Mongodb

You have a collection named restaurants with the geographical information stored in the location property, how do you create a geospatial index on it?

1.

`db.restaurants.CreateIndex({location: "2dsphere"})`

2.

`db.restaurants.geospatial({location: "2dsphere"})`

3.

`db.restaurants.CreateIndex("2dsphere":"location")`

4.

`db.restaurants.CreateIndex({geospatial: "location"})`

Q 18 / 76

Mongodb

How do you find documents with a matching item in an embedded array?

1.

`db.customers.findmatch ({"jobs":"secretary"})`

2.

`db.customers.find ({"jobs:secretary"})`

3.

`db.customers.find ({"jobs":["secretary"]})`

4.

`db.customers.find ({"jobs":"secretary"})`

Q 19 / 76

Mongodb

Which query bypasses the first 5 customers and returns the next 10?

1.

`db.customers.find({}, {skip: 5, limit: 10})`

2.

`db.customers.find({}.page(5).take(10))`

3.

`db.customers.find({}).skip(5).take(10)`

4.

`db.customers.find({}).skip(5).limit(10)`

Q 20 / 76

Mongodb

How do you create a text index?

1.

`db.customers.createIndex({firstName, lastName})`

2.

`db.customers.createTextIndex({firstName, lastName})`

3.

`db.customers.createIndex({firstName: "text", lastName: "text"})`

4.

`db.customers.createText({firstName: 1, lastName: 1})`

Q 21 / 76

Mongodb

Assuming you have customers collection with a firstName and lastName field, which is the correct MongoDB shell command to create an index on lastName, then firstName both ascending?

1.

`db.customers.createIndex("lastName, firstName, ASC")`

2.

`db.customers.addIndex({lastName:"ASC", firstName: "ASC"})`

3.

`db.customers.newIndex({lastName:1, firstName:1})`

4.

`db.customers.createIndex({lastName:1, firstName: 1})`

Q 22 / 76

Mongodb

One of the documents in your collection has an _id based upon an older database design and you want to change it. You write an update command to find the document and replace the _id but the _id isn't changed. How should you fix the issue?

1.

Set the replace option to true.

2.

Use the replaceOne() command instead.

3.

You can't. Once set, the _id field cannot be changed.

4.

Use the updateOne() command instead.

Q 23 / 76

Mongodb

A compound index allows you to _ ?

1.

Calculate interest quickly.

2.

Accomplish nothing, since compound indexes aren't allowed in Mongo.

3.

Use more than one field per index.

4.

Combine fields in different collations.

Q 24 / 76

Mongodb

Why are ad-hoc queries useful?

1.

They do not have to use the same operators.

2.

You do not need to structure the database to support them.

3.

They autogenerate reports.

4.

They run faster than indexed queries.

Q 25 / 76

Mongodb

How often do the members of a replica set send heartbeats to each other?

1.

every 2 minutes

2.

every 5 seconds

3.

every 2 seconds

4.

every 10 seconds

Q 26 / 76

Mongodb

Which command returns all of the documents in the customers collection?

1.

`db.customers.all();`

2.

`db.find().customers();`

3.

`db.customers.find();`

4.

`db.customers.show();`

Q 27 / 76

Mongodb

Given a cursor named myCursor, pointing to the customers collection, how to you get basic info about it?

1.

`myCursor.stats()`

2.

`myCursor.dump()`

3.

`myCursor.info()`

4.

`myCursor.explain()`

Q 28 / 76

Mongodb

What is true about indexes?

1.

They speed up read access while slowing down writes.

2.

They secure the database from intruders.

3.

They speed up reads and writes.

4.

They speed up write access while slowing down reads.

Q 29 / 76

Mongodb

What is the preferred format to store geospatial data in MongoDB?

1.

Latitude, longitude

2.

XML

3.

GeoJSON

4.

BSON

Q 30 / 76

Mongodb

Which programming language is used to write MongoDB queries? (_Alternative_: In the MongoDB shell, what programming language is used to make queries?)

1.

Python

2.

JavaScript

3.

SQL

4.

TypeScript

Q 31 / 76

Mongodb

You have two text fields in your document and you'd like both to be quickly searchable. What should you do?

1.

Create a text index on each field.

2.

MongoDB is not able to do this.

3.

Create a compound text index using both fields.

4.

Create a text index on one field and a single field index on the other.

Q 32 / 76

Mongodb

To import a CSV file into MongoDB, which command should you issue?

1.

mongorestore

2.

mongoi

3.

upload

4.

mongoimport

Q 33 / 76

Mongodb

In an MongoDB mapReduce command, the reduce function should _.

1.

access the database

2.

be called only when the key has a single value

3.

access the database only to perform read operations

4.

not access the data

Q 34 / 76

Mongodb

On a newly created collection, which field will have an index?

1.

the name field

2.

the ObjectId field

3.

the `_id` field

4.

no field will have an index

Q 35 / 76

Mongodb

You have a collection of thousands of students. You'd like to return the second set of 20 documents from the sorted collection. What is the proper order in which to apply the operations?

1.

limit, skip, sort

2.

sort, limit, skip

3.

limit, sort, skip

4.

sort, skip, limit

Q 36 / 76

Mongodb

You would like the stats() command to return kilobytes instead of bytes. Which command should you run?

1.

`db.vehicle.stats(1024)`

2.

`db.vehicle.stats("kilobytes")`

3.

`db.vehicle.stats(true)`

4.

`db.vehicle.stats("kb")`

Q 37 / 76

Mongodb

You want to modify an existing index. What is the best way to do this?

1.

Use the `reIndex()` command to modify the index.

2.

Delete the original index and create a new index.

3.

Call the `createIndex()` command with the update option.

4.

Use the `updateIndex()` command.

Q 38 / 76

Mongodb

You need to delete the index you created on the description field. Which command will accomplish this?

1.

`db.vehicle.dropIndex("description_text")`

2.

`db.vehicle.dropIndex({"description":"text"})`

3.

`db.vehicle.removeIndex({"description":"text"})`

4.

`db.vehicle.removeIndex("description_text")`

Q 39 / 76

Mongodb

You would like to know how many different categories you have. Which query will best get the job done?

Note: count() works with find(...) but length works with distinct

1.

`db.vehicle.distinct("category")`

2.

`db.vehicle.unique("category")`

3.

`db.vehicle.distinct("category").count()`

4.

`db.vehicle.distinct("category").length`

Q 40 / 76

Mongodb

From the MongoDB shell, how do you create a new document in the customers collection?

1.

`db.customers.add({name: "Bob"})`

2.

`db.customers.save({name: "Bob"})`

3.

`db.customers.create({name: "Bob"})`

4.

`db.customers.new({name: "Bob"})`

Q 41 / 76

Mongodb

Which field is required of all MongoDB documents?

1.

`_id`

2.

`_name`

3.

ObjectId

4.

mongoDB is schema-less so no field is required

Q 42 / 76

Mongodb

A MongoDB instance has at least what three files?

1.

data, namespace, and journal

2.

namespace, journal, and log

3.

journal, data, and database

4.

data, log, and journal

Q 43 / 76

Mongodb

You'd like a set of documents to be returned in last name, ascending order. Which query will accomplish this?

1.

`db.persons.find().sort({lastName: -1}}`

2.

`db.persons.find().sort({lastName: 1}}`

3.

`db.persons.find().sort({lastName: ascending}}`

4.

`db.persons.find().sort({lastName: $asc}}`

Q 44 / 76

Mongodb

What is NOT a standard role in MongoDB?

1.

restore

2.

read/write

3.

dbadmin

4.

delete collections

Q 45 / 76

Mongodb

Which MongoDB shell command deletes a single document?

1.

`db.customers.delete({_id: 1});`

2.

`db.customers.drop({_id: 1});`

3.

`db.drop.customers({_id: 1});`

4.

`db.customers.remove({_id: 1});`

Q 46 / 76

Mongodb

Using the MongoDB shell, how do you remove the customer collection and its indexes?

1.

`db.customers.remove({}).indexes();`

2.

`db.customers.remove({});`

3.

`db.customers.drop();`

4.

`db.customers.delete();`

Q 47 / 76

Mongodb

By default, applications direct their read operations to which member of the replica set?

1.

primary

2.

arbiter

3.

secondary

4.

backup

Q 48 / 76

Mongodb

You need to get the names of all the indexes on your current collection. What is the best way to accomplish this?

1.

`db.people.getName();`

2.

`db.people.reIndex({names: 1});`

3.

`db.people.getIndexKeys();`

4.

`db.people.getIndexes();`

Q 49 / 76

Mongodb

You are going to do a series of updates to multiple records. You find setting the multi option of the update() command too tiresome. What should you do instead?

1.

Use the replaceMany() command instead

2.

Use the updateMulti() command instead

3.

Use the updateMany() command instead

4.

Set the global multi option to True

Q 50 / 76

Mongodb

To cleanly shut down MongoDB, what command should you use from the MongoDB shell?

1.

quit()

2.

exit()

3.

db.shutdownServer()

4.

db.shutdown()

Q 51 / 76

Mongodb

Given a customer collection which includes fields for gender and city, which aggregate pipeline shows the number of female customers in each city? (_Alternative_: How can you view the execution performance statistics for a query?)

1.

`db.members.aggregate([ {$match: {gender: "Female"}}, {$group: {_id: {city: "$city"}, number: {$sum: 1}}}, {$sort :{number: -1}}])`

2.

`db.members.find({$match: {gender: "Female"}}, {$group: {_id: {city: "$city"}, number: {$sum: 1}}}.$sort ({number: -1})`

3.

`db.members.find([ {$match: {gender: "Female"}}, {$group: {_id: {city: "$city"}, number: {$sum: 1}}}, {$sort :{number: -1}}])`

4.

`db.members.aggregate([ {$match: {gender: "Female"}}, {$sort :{number: -1}}])`

Q 52 / 76

Mongodb

When no parameters are passed to `explain()`, what mode does it run in?

1.

wireTiger mode

2.

executionStats mode

3.

queryPlanner mode

4.

allPlansExecution mode

Q 53 / 76

Mongodb

What is the correct query to find all of the people who have a home phone number defined?

1.

`db.person.find({exists: 'homePhone'});`

2.

`db.person.exists({homePhone: true});`

3.

`db.person.find({homePhone: {$exists: true}});`

4.

`db.person.has('homePhone');`

Q 54 / 76

Mongodb

Which file in the MongoDB directly holds the MongoDB daemon?

1.

mongodb

2.

mongo-daemon

3.

daemon

4.

mongod

Q 55 / 76

Mongodb

You have just secured your previously unsecured MongoDB server, but the server is still not requiring authentication. What is the best option?

1.

Restart the `mongod` process.

2.

Issue the `secure()` command.

3.

Issue the `mongoimport` command.

4.

Issue the `authenticate()` command.

Q 56 / 76

Mongodb

What is the most accurate statement regarding MongoDB and ad hoc queries?

1.

MongoDB does not allow ad hoc queries; all queries require an index.

2.

Ad hoc queries are allowed only in the paid version.

3.

Ad hoc queries are allowed only through the ad hoc command.

4.

MongoDB allows ad hoc queries.

Q 57 / 76

Mongodb

In MongoDB, what does a projection do?

1.

allows you to do a calculation on the results

2.

allows you to run queries on the server

3.

allows you to select which fields should be in the return data

4.

allows you to format the results for a display

Q 58 / 76

Mongodb

To remove a database and all of its records from MongoDB, what operator should you use?

1.

`dropDatabase()`

2.

`removeAll()`

3.

`clear()`

4.

`deleteDatabase()`

Q 59 / 76

Mongodb

What option can be passed to start the MongoDB shell without connecting to a database?

1.

`-db=null`

2.

`--shell-only`

3.

`--free`

4.

`-nodb`

Q 60 / 76

Mongodb

How can you improve the appearance of the output JSON that contains the `_id`?

1.

`Use db.collection.set({$_id:pretty})`

2.

`Create a second index`

3.

`Use db.collection.format(numeric)`

4.

`Use $_id = value`

Q 61 / 76

Mongodb

What happens to a Replica set oplog if it runs out of memory?

1.

`The oplog will be saved on one of the secondary servers.`

2.

`The oplog is capped collection and can't run out of memory`

3.

`The MongoDB instance will fail`

4.

`The oplog will stop recording logging information`

Q 62 / 76

Mongodb

MongoDB ships with a variety of files. Which file runs the MongoDB shell?

1.

mongo

2.

mongo-s

3.

shell

4.

mongo-shell

Q 63 / 76

Mongodb

How can you view the execution performance statistics for a query?

1.

`db.performance.members.aggregate([ {$match: {gender: "Female"}}, {$group: {_id:{city:"$city"}, number: {$sum: 1}}}, {$sort : {number: -1}}])`

2.

`db.members.aggregate([ {$match: {gender: "Female"}}, {$group: {_id: {city: "$city"}, number:{$sum:1}}}, {$sort: {number:-1}}]).explain("executionStats")`

3.

`db.members.aggregate([ {$match: {gender: "Female"}}, {$group:{_id: {city: "$city"}, number: {$sum: 1}}}, {$sort: {number: -1}}]).explain()`

4.

`db.members.aggregate([ {$match: {gender: """Female"""}}, {$group: {_id: {city: """$city"""}, number: {$sum:1}}}, {$sort: {number: -1}}]).number()`

Q 64 / 76

Mongodb

From the MongoDB shell, how do you execute a JavaScript file named list.js?

1.

node 'list.js'

2.

exec('list.js)

3.

run('list.js)

4.

load('list.js)

Q 65 / 76

Mongodb

Which MongoDB shell query will sort the customer's collection by name descending?

1.

db.customers.sort({name: -1}.find({})

2.

db.customers.sort({name: -1})

3.

db.customers.find({}).sort({name: -1})

4.

db.customers.find({}).sort({name: 1})

Q 66 / 76

Mongodb

Suppose you are using the mongoimport command to import personnel data and there is a unique index on the email field. What happens when there are duplicate emails in the import?

1.

The import command aborts without importing any records.

2.

The import command imports records upto but not including the record, and then aborts.

3.

The import command doesn't import the bad document but does import the rest.

4.

The import command prompts you to correct the bad record.

Q 67 / 76

Mongodb

You have a collection with millions of documents. Each time you attempt to sort. MongoDB runs out of memory. What might help?

1.

Use the purge operator before the sort.

2.

Return the entire collection and sort on the client.

3.

Pass the --more-memory option.

4.

Create an index on the field you are sorting.

Q 68 / 76

Mongodb

You need to be able to quickly find a word in a text field. What should you do?

1.

Create a text index on the field and do a $text Query.

2.

Create an single field index in descending order, and do a query for the word.

3.

Do a $text query.

4.

Create a $regex on the fields, and do a $regex query.

Q 69 / 76

Mongodb

Which field is always included in a projection unless specifically excluded?

1.

index

2.

Name

3.

`_id`

4.

row number

Q 70 / 76

Mongodb

After installing MongoDB on your machine, what must you do before launching Mongo?

1.

Create a user account.

2.

Register online.

3.

Create a data directory.

4.

Establish security credentials.

Q 71 / 76

Mongodb

How does a --jsonArray file need to be structured?

1.

as a properly formatted JSON array

2.

as YAML

3.

as plain text

4.

as a BSON object

Q 72 / 76

Mongodb

From the MongoDB shell, how do you display all of a database's memory usage?

1.

db.size()

2.

db.info()

3.

db.memory()

4.

db.stats()

Q 73 / 76

Mongodb

How do you create a new MongoDB user?

1.

db.createUser({})

2.

db.insert({user: 1})

3.

db.customers.newUser({})

4.

db.newUser({})

Q 74 / 76

Mongodb

What is the internal data structure of a MongoDB document?

1.

JSON (JavaScript Object Notation)

2.

BSON (Binary JSON)

3.

ORM (object relational mode)

4.

MBF (MongoDB binary format)

Q 75 / 76

Mongodb

Which projection shows only the FirstName and lastName fields of a document in the customers collection?

1.

`db.customers.find({}, {firstName: 1, lastName: 1})`

2.

`db.customers.find({}, {_id:0, firstName: 1, lastName: 1})`

3.

`db.customers.find({_id: 0, year: 1, maek: 1, model: 1})`

4.

`db.customers.find({}).project({firstName: 1, lastName: 1})`

Q 76 / 76