Midterm-ModelAnswer
Midterm-ModelAnswer
Faculty of Computers and Artificial Intelligence Year: Third Level – First Term
Mid Term Exam –09 November 2024 Time: 60 minutes
Pages: 3 Pages Mark: 20 points
1
c. limit
d. None of the above
7. The ……… operator tests whether a given array contains at least one item that
satisfies all the involved query operations.
a. $all
b. $elemMatch
c. $size
d. $regex
8. The..............means adding resources to a single node in a system.
a. Replication
b. Sharding
c. Horizontal scaling
d. Vertical scaling
9. Which of the following is a false assumption of horizontal scaling?
a. Network is reliable
b. Network is secure
c. Bandwidth is infinite
d. All the above
10. The ……… property means system continues to operate even when two or more
nodes get isolated.
a. Consistency
b. Durability
c. Partition Tolerance
d. Availability
2
8. The write-write consistency conflict write and read requests on the same
aggregate are initiated concurrently.
9. In master-slave replication architecture all write requests can only be
handled by the master.
10. In sharding + master-slave replication, the data may be duplicated on
different masters.
scientific research
Q2] What are the main drawbacks of vertical scaling?
Proactive provisioning, vendor lock-in, higher costs, deployment down time, single
point of failure, performance limit
Q3] Given the structure of Restaurants collection
2. Write a MongoDB query to update cuisine to “Solid” for restaurant_id 30075445, for
only first matched document.
3
Db.restaurant.updateOne({restaurant_id:
‘30075445’}, {$set: {cuisine: ‘Solid’}})
3. Write a MongoDB query to remove last item in grades array.
Db.restaurant.updateOne({}, {$pop:
{grades: 1}})
4. Write a MongoDB query to delete all documents that have address building 1007.
Db.restaurant.deleteMany({‘address.building’: 1007})
4
5. Write a MongoDB query to sort all documents in restaurants collection in
descending order by name.
• db.restaurant.find({}).sort({name: -1})
6. Write a MongoDB query to find all documents that have names start with string
“Morris”.
Db.resturant.find({name: {$regex: “^Morris.*”}})
Best Wishes