Database and Schema
db.instructor.insertMany( [ { "name": "Zhang", "dept_name": "CS", "salary": 68000, "teaches": [ { course_id: "CS-101", year: 2018 }, { course_id: "CS-347", year: 2018 } ] }, { "name": "Levy", "dept_name": "CS", "salary": 80000, "teaches": [ { course_id: "CS-128", year: 2016 }, { course_id: "CS-201", year: 2017 } ] }, { "name": "Brandt", "dept_name": "Finance", "salary": 90000, "teaches": [ { course_id: "FIN-201", year: 2016 }, { course_id: "FIN-301", year: 2017 }, { course_id: "FIN-320", year: 2017 } ] }, { "name": "Davis", "dept_name": "Finance", "salary": 78000, "teaches": [ { course_id: "FIN-102", year: 2017 }, { course_id: "FIN-200", year: 2018 } ] }, { "name": "Crick", "dept_name": "Biology", "salary": 92000, "teaches": [ { course_id: "BIO-101", year: 2017 }, { course_id: "BIO-301", year: 2018 }, { course_id: "BIO-301", year: 2018 } ] }, { "name": "Williams", "dept_name": "Biology", "salary": 72000, "teaches": [ { course_id: "BIO-101", year: 2016 }, { course_id: "BIO-201", year: 2017 }, { course_id: "BIO-101", year: 2018 } ] } ] );
Queries
Give the MongoDB commands for the following queries and attach the result screenshot of each.
a. Find the name, department name, and the salary of each instructor whose salary is at least 80,000 and has taught three courses. If an instructor has taught the same course N times, it is counted as N courses.
b. Find the name and department name of each instructor who taught in both 2017 and 2018 and sort the results alphabetically by name.
c. Find the total salary of each department and sort the result in the ascending order of the total salary. The result should only display department name and the total salary
Contact us for MongoDB Assignment help, MongoDB Homework Help, MongoDB Query help
Want to know your assignment price quote please send your assignment file at contact@codersarts.com and our sales team will contact you as soon as assignment received.
댓글