Which command in the MongoDB shell displays all available databases?
db.getDatabases()
list databases
show dbs
show databases
How do you establish a connection to a MongoDB database in a Java application using the MongoDB Java driver?
By using the db.connect() method
db.connect()
By calling the connect() method on the MongoDatabase class
connect()
MongoDatabase
By creating a new MongoConnection object
MongoConnection
By creating an instance of the MongoClient class
MongoClient
What is a potential drawback of excessive embedding in MongoDB?
Inability to represent one-to-many relationships effectively
Increased query complexity and reduced performance
Larger document sizes, potentially impacting storage and retrieval speed
Difficulties in updating related data consistently
After adding the MongoDB repository to your system's package manager, which command updates the package list and installs the MongoDB server package?
mongorestore
mongod
sudo apt-get install -y mongodb-org
sudo systemctl start mongod
Which command is used to create an index in MongoDB?
db.collection.insertIndex()
db.collection.ensureIndex()
db.collection.createIndex()
db.collection.addIndex()
What does the $avg operator calculate within the $group stage?
$avg
$group
The minimum value of a field in each group.
The maximum value of a field in each group.
The total count of documents in each group.
The average value of a field in each group.
What is the role of the MongoClient object in a MongoDB Node.js application?
To execute queries against the database
To create and manage user accounts
To establish a connection to the MongoDB server
To define the database schema
In MongoDB, data is stored in BSON format. What does BSON stand for?
Balanced Schema Object Notation
Binary System Object Notation
Basic Serialized Object Notation
Binary Structured Object Notation
What is the primary purpose of indexing in MongoDB?
To compress data and reduce storage space
To enable full-text search capabilities
To store data in a sorted order for faster retrieval
To enforce data integrity and prevent duplicates
What is the command used to connect to a running MongoDB instance from the terminal?
connect_mongodb
mongo
mongodb-connect
start_mongo