Recall & Review
beginner
How do you create a new database in MongoDB?
In MongoDB, you create a new database by switching to it using
use databaseName. The database is created when you first store data in it.Click to reveal answer
beginner
What command creates a new collection explicitly in MongoDB?
Use
db.createCollection('collectionName') to create a new collection explicitly.Click to reveal answer
beginner
True or False: In MongoDB, a database is created immediately when you switch to it with
use.False. The database is created only when you insert the first document into a collection within that database.
Click to reveal answer
beginner
What happens if you insert a document into a collection that does not exist in MongoDB?
MongoDB automatically creates the collection and the database (if not existing) when you insert the first document.
Click to reveal answer
intermediate
Explain the difference between creating a collection explicitly and implicitly in MongoDB.
Explicit creation uses
db.createCollection(). Implicit creation happens automatically when you insert a document into a non-existing collection.Click to reveal answer
Which command switches to a database named 'shop' in MongoDB?
✗ Incorrect
The
use shop command switches to the 'shop' database.How do you explicitly create a collection named 'products'?
✗ Incorrect
Use
db.createCollection('products') to explicitly create a collection.When is a MongoDB database actually created?
✗ Incorrect
The database is created when the first document is inserted into a collection.
What happens if you insert a document into a non-existing collection?
✗ Incorrect
MongoDB creates the collection and database automatically on first insert.
Which of these is NOT a way to create a collection in MongoDB?
✗ Incorrect
SQL commands like CREATE TABLE do not work in MongoDB.
Describe the process of creating a new database and collection in MongoDB.
Think about what happens when you insert data.
You got /3 concepts.
Explain the difference between implicit and explicit collection creation in MongoDB.
One is manual, the other automatic.
You got /3 concepts.