DBVersity MongoDB Assessment tests

Download at : DBVersity_MongoDB_Assessment_papers

DBVersity MongoDB Assessment

 

 

  • MongoDB manages collections of _________ like documents which are internally stored in binary format referred to as BSON?

 

  1. XML
  2. JavaScript
  3. HTML
  4. JSON
  5. All of above

 

  • Purpose of MongoDB Replication and Sharding respectively?

 

  1. Horizontal Scalability & High Availability
  2. High Availability & Horizontal Scalability
  3. Vertical Scalability & Manual Failover
  4. None of above

 

  • Which of the following is correct explanation of MongoDB processes?
  1. A) mongod.exe is the shell process and mongo.exe is the actual database process
  2. B) mongo.exe is the shell process and mongod.exe is the actual database process
  3. C) mongos.exe is the MongoDB server process needed to run database
  4. D) mongodump.exe can be used to import database backup dump

 

  • Which of the following collections are used by MongoDB to store GridFS data?

 

  1. A) fs.files and fs.chunks
  2. B) fs.grid and fs.chunks
  3. C) fs.parts and fs.files
  4. D) fs.chunks and fs.parts

 

  • Which of the following SQL terminology is same as $match in MongoDB?

 

  1. A) WHERE
  2. B) HAVING
  3. C) Both WHERE and HAVING
  4. D) GROUP BY

 

  • In a replica set, a ________ number of members ensures that the replica set is always able to select a primary.

 

 

  1. A) Odd
  2. B) Even
  3. C) Depends on the application architecture
  4. D) 2

 

 

 

  • Which of the following is a valid MongoDB JSON document:

 

A  {}

 

B  {

“user_id”=1,

“user_name”=”Joe “,

“occupation”=[“engineer”,”writer”]

}

 

C {

“user_id”:1;

“user_name”:”Joe “;

“occupation”:[“engineer”,”writer”]

}

 

D {

“user_id”:1,

“user_name”:”Joe “,

“occupation”:[

“occupation1″:”engineer”,

“occupation2″:”writer”

]

}

 

 

 

  • What is the output of following two commands in MongoDB:

 

db.posts.insert({“_id”:1})

db.posts.insert({“_id”:1})

 

  1. A) Two documents will be inserted with _id as 1
  2. B) MongoDB will automatically increment the _id of the second document as 2
  3. C) This will throw a duplicate key error
  4. D) It will insert two documents and throw a warning to the user

 

 

 

  • Which of the following command is used to get all the indexes on a collection?

 

  1. A) db.collection.getIndexes()
  2. B) db.collection.showIndexes()
  3. C) db.collection.findIndexes()
  4. D) db.showIndexes()

 

 

  • Which of the following methods can be used in MongoDB for relation documents?

 

  1. A) SQL Joins
  2. B) References/DBRefs
  3. C) Aggregations
  4. D) There is no concept of relations in documents

 

 

  • Which type of indexes does MongoDB support?

 

  1. A) Compound Indexes
  2. B) Text Indexes
  3. C) Geospatial Indexes
  4. D) All of the above

 

  • Consider a collection posts which has fields: _id, post_text, post_author, post_timestamp, post_tags etc. Which of the following query retrieves ONLY the key named post_text from the first document retrieved?

 

  1. A) db.posts.find({},{_id:0, post_text:1})
  2. B) db.posts.findOne({post_text:1})
  3. C) db.posts.findOne({},{post_text:1})
  4. D) db.posts.findOne({},{_id:0, post_text:1})

 

 

 

  • What kind of database MongoDB is?

 

A)Graph Oriented

B)Document Oriented

C)Key Value Pair

D)Column Based

 

 

 

 

  • Which is the default mode in which the explain() command runs?

 

A)queryPlanner

B)executionStats

C)allPlansExecution

D)customExecutionStats

 

 

 

 

  • In a sharded replica set environment, the w Option provides ability for write concern and j Option provides ability for the data to be written on disk journal. Consider that we have a seven member replica set and we want to assure that the writes are committed to journal. What should be the value of j?

 

A)0

B)1

C)2

D)7

 

 

 

 

  • Given the following posts document:

 

{

    “_id” : 1,

    “post_text” : “This post does not matter”,

    “tags”: [ “tutorial”, “fun”, “learning”],

    // rest of the document

}

What will be the output of following query:

 

db.posts.aggregate( [ { $unwind : “$tags” } ] )

 

A)Return three separate documents for three separate tags

B)Arranges the tags (wind) in ascending order

C)Arranges the tags (wind) in descending order

D)Returns one document but converts the tags array in an object

 

 

 

 

  • In a posts collection, which command can be used to find all the posts whose author names begin lie between “A” and “C” in dictionary order?

 

A)db.posts.find( { post_author : { $gte : “A” , $lte : “C” } } );

B)db.posts.find( { post_author : { $gte : “C” , $lte : “A” } } );

C)db.posts.find( { post_author : { $gt : “A” , $lt : “C” } } );

D)This type of search is not supported by MongoDB. $lt and $gt operators are applicable only for numeric values.

 

 

  • What does the output x of the following MongoDB aggregation query result into:

 

db.posts.aggregate( [ { $group: { _id: “$author”, x: { $sum: “$likes” } } } ] )

 

A)Average of likes on all the posts of an author, grouped by author

B)Number of posts by an author

C)Sum of likes on all the posts by an author, grouped by author

D)Sum of likes on all the posts by all the authors

 

 

 

 

  • Suppose that you have the following three documents in your system:

 

{ _id: 1, product_code: “123456”, description: “mongo db tutorial” }

{ _id: 2, product_code: “345567”, description: “this is mongo tutorial” }

{ _id: 3, product_code: “123431”, description: “my mongo” }

 

If you create a text index on the description field and then apply a text search on term “mongo”, which all documents will be fetched.

 

A)1 and 2

B)2 and 3

C)1 and 3

D)All of the above

 

 

 

  • Which of the following methods can be used on a cursor object?

 

A)cursor.next()

B)cursor.hasNext()

C)cursor.forEach()

D)All of the above

 

 

 

  • Which of the following is not a system collection in MongoDB?

 

A)database.system.indexes

B)database.system.namespaces

C)admin.system.users

D)admin.system.preferences

 

 

 

 

  • What does the following aggregate query perform?

 

db.posts.aggregate( [

       { $match : { likes : { $gt : 100, $lte : 200 } } },

       { $group: { _id: null, count: { $sum: 1 } } }

] );

 

A)Calculates the number of posts with likes between 100 and 200

B)Groups the posts by number of likes (101, 102, 103) by adding 1 every time

C)Fetches the posts with likes between 100 and 200 and sets their _id as null

D)Fetches the posts with likes between 100 and 200, sets the _id of the first document as null and then increments it 1 every time

 

  • What happens if an index does not fit into RAM?

 

 

 

 

  • How is MongoDB better than other SQL databases?

 

 

 

  • What does pretty() in MongoDB query will do ?

  • Ask Question