Consider a MongoDB database containing a collection of documents representing product information for an e-commerce website. The documents have the following structure:
{ "username": "user3", "rating": 3, "comment": "Good but overpriced." }
]
}
Select the MongoDB aggregation pipeline that returns the average rating of all products grouped by brand. The result should include only brands with an average rating greater than or equal to 4. The output should have the following format:
Answer: D
Question 2
You are designing a MongoDB schema for an e-commerce platform. The system has three collections: Products, Categories, and Reviews.Products Collection: Contains information about each product, including its name, price, and categoryId referencing the Categories collection.Categories Collection: Contains the category name and description.Reviews Collection: Contains user reviews for products, including the productId referencing the Products collection, userId, rating, and reviewText.Which of the following is the best approach to model the relationships between Products, Categories, and Reviews in MongoDB?
Answer: A
Question 3
Suppose you insert the following documents into a companies collection:
db.companies.insertMany([
{"name": "Facebook"},
{"name": "X"}
])
Select all true statements about this command. (Select three)
Answer: C,D,E
Question 4
You have a MongoDB collection named employees that contains documents with fields name, department, and salary. You want to update the salary of all employees in the "Marketing" department to $75,000. The original collection looks like this: