0
0
MongoDBquery~10 mins

Database and collection creation in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new database named 'school'.

MongoDB
use [1]
Drag options to blanks, or click blank then click option'
Alibrary
Bstore
Cschool
Doffice
Attempts:
3 left
💡 Hint
Common Mistakes
Using a database name other than 'school'.
Forgetting to use the 'use' command.
2fill in blank
medium

Complete the code to create a collection named 'students' in the current database.

MongoDB
db.[1].insertOne({name: 'Alice', age: 20})
Drag options to blanks, or click blank then click option'
Astudents
Bcourses
Cteachers
Dclasses
Attempts:
3 left
💡 Hint
Common Mistakes
Using a collection name other than 'students'.
Trying to create a collection without inserting a document.
3fill in blank
hard

Fix the error in the code to create a collection named 'books'.

MongoDB
db.createCollection('[1]')
Drag options to blanks, or click blank then click option'
Abooks
BbooksCollection
Cbooks.create
Dbooks.createCollection
Attempts:
3 left
💡 Hint
Common Mistakes
Using create() method on a collection.
Confusing collection name with method name.
4fill in blank
hard

Fill both blanks to explicitly create a collection named 'employees' in the 'company' database.

MongoDB
use [1]
db.[2]('employees')
Drag options to blanks, or click blank then click option'
Acompany
Bemployees
CcreateCollection
Dstaff
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong database name.
Using wrong method to create collection.
5fill in blank
hard

Fill all three blanks to create a database 'library', create a collection 'books', and insert a document with title '1984'.

MongoDB
use [1]
db.[2].[3]({title: '1984'})
Drag options to blanks, or click blank then click option'
Alibrary
Bbooks
CinsertOne
DinsertMany
Attempts:
3 left
💡 Hint
Common Mistakes
Using insertMany when only one document is inserted.
Using wrong collection or database names.