JUST NEED THE COMMANDS 2. Import students.json from https://github.com/ozlerhaka
ID: 3704136 • Letter: J
Question
JUST NEED THE COMMANDS
2. Import students.json from https://github.com/ozlerhakan/mongodb-json-files/blob/master/datasets/students.json into your Database, and collection students (already did this, just showing you the type of data that's being used)
3. Write and Run a Mongo Shell command which is equivalent to "SELECT * FROM students WHERE exam score < 23"
4. Write and Run a Mongo Shell command which is equivalent to "SELECT * FROM students WHERE name LIKE '%SKI"
5. Write and Run a Mongo Shell command which is equivalent to "UPDATE students SET quiz score=53 WHERE student ID = 15"
6. Write and Run a Mongo Shell command which is equivalent to "SELECT * FROM students WHERE average of all three scores > 80
7. Write and Run a Mongo Shell command which is equivalent to "SELECT average(exam), average(quiz), average (homework) FROM students"
8. Write and Run a Mongo Shell command which is equivalent to "DELETE FROM students WHERE student id=10"
Explanation / Answer
3) Finding all the students with score less than 23 and score type is exam.
db.students.find({$and:[scores.score:{$lt:23}, {"scores.type":"exam"}]})
4) Finding student with names starts with SKI.
db.students.find({"name": SKI/})
5) Updating score as 53 where score type is quiz and id is 15.
db.students.update({_id:15,"scores.type":"quiz"},{$set:{score:53}})
7) Find the aggregate avg of score type.
db.students.aggregate([
{
$group: {
_id: "scores.type",
average: {$avg: "$score"}
}
}
])
8) Removing the recore with id 10.
db.students.remove({_id:10})
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.