0
0
MongoDBquery~10 mins

Normalization vs denormalization default in MongoDB - Interactive Practice

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

Complete the code to find all documents in the collection.

MongoDB
db.collection.[1]()
Drag options to blanks, or click blank then click option'
Afind
Binsert
Cupdate
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using insert() instead of find() to retrieve data.
Using update() or delete() which modify data instead of reading.
2fill in blank
medium

Complete the code to insert a new document into the collection.

MongoDB
db.collection.[1]({ name: 'Alice', age: 30 })
Drag options to blanks, or click blank then click option'
Afind
BupdateOne
CinsertOne
DdeleteOne
Attempts:
3 left
💡 Hint
Common Mistakes
Using find() which only reads data.
Using updateOne() which changes existing data.
3fill in blank
hard

Fix the error in the query to update a document's age.

MongoDB
db.collection.updateOne({ name: 'Bob' }, { [1]: { age: 35 } })
Drag options to blanks, or click blank then click option'
Aupdate
B$set
Cset
D$update
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the '$' sign before set.
Using 'update' instead of '$set'.
4fill in blank
hard

Fill both blanks to query documents where age is greater than 25.

MongoDB
db.collection.find({ age: { [1]: [2] } })
Drag options to blanks, or click blank then click option'
A$gt
B$lt
C25
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt which means less than.
Using wrong comparison number.
5fill in blank
hard

Fill all three blanks to create a denormalized document with embedded address.

MongoDB
db.collection.insertOne({ name: 'Eve', age: 28, address: { [1]: '123 Main St', [2]: 'Springfield', [3]: 'IL' } })
Drag options to blanks, or click blank then click option'
Astreet
Bcity
Cstate
Dzipcode
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'zipcode' instead of 'state' for the third blank.
Not embedding address as a sub-document.