C100DEV

C100DEV practice questions, page 2 of 4, with answer review and explanations.

Question 6

Which two are valid MongoDB BSON types? (Choose two.)

  1. Boolean
  2. Float
  3. Number
  4. Double
  5. Map

Question 7

A products collection needs to update the value of the qty field to 100 for a document with a “card” item value. It should insert a new document if it does not exist.What command should be used?

  1. db.products.updateOne({ item: “card”} , { $set: { qty: 100 } }, { $upsert: true })
  2. db.products.insertOne( { item: “card”} , { $set: { qty: 100 } }, { $upsert: true })
  3. db.products.insertOne( { item: “card”} , { $set: { qty: 100 } }, { upsert: true })
  4. db.products.updateOne({ item: “card”} , { $set: { qty: 100 } }, { upsert: true })

Question 8

Given the following documents in the employees collection:{ _id: 0, name: “Y.B.”, department: “Sales” },{ _id: 1, name: “E.H.”, department: “Engineering” },{ _id: 2, name: “C.Y.”, department: “Support” },What mongosh command will find a document with name “E.H.”?

  1. db.employees.query_one( {name: “E.H.”} )
  2. db.employees.find_one( {name: “E.H.”} )
  3. db.employees.queryOne( {name: “E.H.”} )
  4. db.employees.findOne( {name: “E.H.”} )

Question 9

Given the following query:db.restaurants.find({“borough” : “Brooklyn” , “grades.score” : {$gt:5}})No index exists for the restaurant collection.What index definition most improves the performance?

  1. db.restaurants.createIndex({“borough” : 1, “grades.score” : 1} )
  2. db.restaurants.createIndex({“grades.score” : 1, “borough” : 1} )
  3. db.restaurants.createIndex({“borough” : 1} )
  4. db.restaurants.createIndex({“grades.score” : 1} )

Question 10

There is a collection of patients for a medical practice.Which two attributes associated with the patient should be embedded into the patient document rather than stored in its own collection and referenced? (Choose two.)

  1. Visits to the practice
  2. Current prescriptions
  3. Diagnosed conditions
  4. Their primary doctor
  5. Their insurance provider