logo

Crowdly

Browser

Add to Chrome

Alice wants to create two collections in MongoDB called the unitEnrolment coll...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Alice wants to create two collections in MongoDB called the unitEnrolment collection and

the student collection. The relationship between the two collections is one-to-many. One

document in the unitEnrolment collection has many related documents in the student collection.

She wrote the following two MongoDB shell commands to populate the database:

db.unitEnrolment.insertOne({

"_id":1, "code":"FIT5148", "students":[1,2,3,4,5]

})

db.student.insertMany([

{"_id":1,"name":"Alita"},

{"_id":4,"name":"Nick"},

{"_id":5,"name":"Tom"}

])

Alice’s aggregation pipeline code produces the following output:

{"_id" : 1, "students" : 1, "details" : [{ "_id" : 1, "name" : "Alita" }]}

{"_id" : 1, "students" : 2, "details" : [ ] }

{"_id" : 1, "students" : 3, "details" : [ ] }

{"_id" : 1, "students" : 4, "details" : [ { "_id" : 4, "name" : "Nick" } ] }

{"_id" : 1, "students" : 5, "details" : [ { "_id" : 5, "name" : "Tom" } ] }

Which of the following aggregation query will produce the above output?

100%
0%
0%
0%
More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome