Hint: Embed as nested object, not separate or string [OK]
Common Mistakes:
Placing embedded document outside main document
Using array instead of object for one-to-one
Storing embedded data as string
3. Given the document { _id: 1, name: 'Bob', address: { street: 'Main St', city: 'LA' } }, what will be the result of the query db.users.findOne({ _id: 1 })?
Hint: findOne returns entire matching document including embedded [OK]
Common Mistakes:
Expecting only top-level fields returned
Thinking embedded fields are separate documents
Assuming query returns null if embedded exists
4. You have this document: { _id: 2, name: 'Carol', profile: { age: 25, city: 'Chicago' } }. Which update command correctly changes the city to 'Boston' using one-to-one embedding?
Hint: Use dot notation to update embedded fields [OK]
Common Mistakes:
Replacing whole embedded document instead of one field
Using incorrect field path without dot notation
Using invalid bracket notation in update
5. You want to design a MongoDB schema for users and their passports using one-to-one embedding. Which design is best and why?
hard
A. Embed passport details inside user document because passports are small and tightly linked.
B. Store passports in a separate collection and reference user IDs to avoid large documents.
C. Duplicate passport data in both user and passport collections for faster writes.
D. Store passport as a string field inside user document to simplify queries.
Solution
Step 1: Analyze data relationship and size
Passports are small and tightly connected to users, perfect for embedding.
Step 2: Choose embedding benefits
Embedding keeps related data together, simplifies queries, and improves read speed.
Step 3: Evaluate other options
Store passports in a separate collection and reference user IDs to avoid large documents adds complexity with references. Duplicate passport data in both user and passport collections for faster writes duplicates data causing inconsistency. Store passport as a string field inside user document to simplify queries stores data as string losing structure.
Final Answer:
Embed passport details inside user document because passports are small and tightly linked. -> Option A
Quick Check:
Small, tightly linked data = embed [OK]
Hint: Embed small, tightly linked data for simplicity and speed [OK]
Common Mistakes:
Choosing references for small one-to-one data
Duplicating data causing inconsistency
Storing structured data as plain string
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.