What type of database is MongoDB?
A
Relational B
Graph C
Document-oriented D
Key-value store
Analysis & Theory
MongoDB is a document-oriented NoSQL database that stores data in BSON (Binary JSON) format.
What is the default port MongoDB runs on?
A
27017 B
3306 C
5432 D
8080
Analysis & Theory
MongoDB runs on port 27017 by default.
In MongoDB, a **collection** is similar to what in a relational database?
A
Row B
Table C
Database D
Column
Analysis & Theory
A MongoDB collection is equivalent to a table in relational databases.
What is a **document** in MongoDB?
A
A JSON-like data structure B
A table C
A SQL query D
A CSV row
Analysis & Theory
A document in MongoDB is a JSON-like object (BSON) that holds data in key-value pairs.
Which of the following command is used to view all databases in MongoDB shell?
A
SHOW ALL B
LIST DATABASES C
show dbs D
db.show()
Analysis & Theory
`show dbs` lists all available databases in the MongoDB shell.
What is the command to switch to a database named `test`?
A
use test B
switch test C
db test D
open test
Analysis & Theory
`use test` switches the context to the `test` database in MongoDB shell.
Which method inserts one document into a collection?
A
addOne() B
insert() C
insertOne() D
create()
Analysis & Theory
`insertOne()` is used to insert a single document into a MongoDB collection.
What data format is used internally by MongoDB to store documents?
A
JSON B
XML C
BSON D
YAML
Analysis & Theory
MongoDB uses BSON (Binary JSON) internally for storing documents.
Which of the following is a valid MongoDB query to find all documents in a collection?
A
db.collection.findAll() B
db.collection.all() C
db.collection.find({}) D
db.collection.search()
Analysis & Theory
`db.collection.find({})` returns all documents in a collection.
Which command shows all the collections in the current database?
A
show collections B
list collections C
db.showCollections() D
get collections
Analysis & Theory
`show collections` lists all the collections in the current database in MongoDB shell.