0% found this document useful (0 votes)
26 views5 pages

Les99 Mongo Practice Questions

dbs311

Uploaded by

khushisingh11116
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Les99 Mongo Practice Questions

dbs311

Uploaded by

khushisingh11116
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Mogo questions

Choose from thee following operators. Which one cane be used to control the number of items from an array that a query will return
A SelemMatch
B $slice
C$
4 MongoDB does not support partial retrieval of items from an array

MoongoDB is a schema-less design


True or False

Which of the following operation add a new document to a collection


A Create
B update
C insert
D delete
Answer A and C

What is the special key added by MongoDB in each document of a collection


_id
_key
_no
_sno

What kind of database is MngoDB


A - Graph Oriented
B - Document Oriented
C - Key Value Pair
D - Column Based

Q 2 - A collection and a document in MongoDB is equivalent to which of the SQL concepts respectively?
A - Table and Row
B - Table and Column
C - Column and Row
824457596.docx by rt -- 6 December 2024 1 of 5
D - Database and Table

Q 6 - 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?
A - db.posts.find({},{_id:0, post_text:1})
B - db.posts.findOne({post_text:1})
C - db.posts.finOne({},{post_text:1})
D - db.posts.finOne({},{_id:0, post_text:1})

Q 8 - In a collection that contains 100 post documents, what does the following command do?
db.posts.find().skip(5).limit(5)
A - Skip and limit nullify each other. Hence returning the first five documents.
B - Skips the first five documents and returns the sixth document five times
C - Skips the first five documents and returns the next five
D - Limits the first five documents and then return them in reverse order

Q 9 - Which of the following MongoDB query is equivalent to the following SQL query:
UPDATE users SET status = "C" WHERE age > 25
A
db.users.update(
{ age: { $gt: 25 } },
{ status: "C" })
B
db.users.update(
{ age: { $gt: 25 } },
{ $set: { status: "C" } })
C
824457596.docx by rt -- 6 December 2024 2 of 5
db.users.update(
{ age: { $gt: 25 } },
{ $set: { status: "C" } },
{ multi: true })
D
db.users.update(
{ age: { $gt: 25 } },
{ status: "C" },
{ multi: true })

Q 13 - 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

Q 17 - Which of the following commands finds all the documents in the posts collection with post timestamp field as null?
A - db.posts.find( { post_timestamp : { $type: 10 } } )
B - db.posts.find( { post_timestamp: { $type: null } } )
C - db.posts.find( { post_timestamp: { $fieldtype: 10 } } )
D - db.posts.find( { post_timestamp: { $fieldtype: null } } )

Q 19 - Which of the following command can be used in mongo shell to show all the databases in your MongoDB instance?
A - show dbs
B - show databases
824457596.docx by rt -- 6 December 2024 3 of 5
C - show dbs -all
D - ls dbs

Q 25 - In our 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.

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


A - WHERE
B - HAVING
C - Both WHERE and HAVING
D - GROUP BY

A collection in MongoDB is a group of --------


Related documents
Schema
Rows
Databases

824457596.docx by rt -- 6 December 2024 4 of 5


PL?SQL

824457596.docx by rt -- 6 December 2024 5 of 5

You might also like