ASSIGNMENT 4 Due Date: December 3, 2023 (11:59 pm) In this assignment, you will use MongoDB...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
ASSIGNMENT 4 Due Date: December 3, 2023 (11:59 pm) In this assignment, you will use MongoDB query language to read, process, and extract data from MongoDB collections. The first part of the assignment involves writing "simple MongoDB queries" using the find() method. The second part of the assignment involves writing "advanced MongoDB queries" using the MongoDB aggregation pipeline. For each question, your answer should be a single MongoDB statement (i.e., there should be a piece of code starting with db.collection.method() and ending with a semi-column). Save your answers to a text file. Do NOT forget to write your group number and the names of all the members in your group at the top the file using comment lines (/* Group x*/) (/* Member 1 Name*/) (/* Member 2 Name*/) Use a comment line to indicate which question the subsequent query answers (such as /*Answer to Question X*/). Submit a soft copy of your assignment (one submission per group) by the due date (refer to the class syllabus for late submission penalties). You can make only ONE attempt. Therefore, do NOT submit your assignment prematurely if you think that you can make changes on your solution later. Good luck! Part 1: Writing Simple MongoDB Queries We have a collection of researchers named "scientists" (see the scientists.json file). This collection keeps track of basic information about researchers, like their name, birth date, death date (if any), contributions to the scientific world, awards received for their contributions. Each document has a unique_id field and looks like this: { _id: 1, name: { first "John", last "Backus" }, birth ISODate("1924-12-03T05:00:00Z"), death ISODate("2007-03-17T04:00:00Z"), contribs [ ] "Fortran", "ALGOL", "FP" ], awards [ { { award: "W.W. McDowell Award", year: 1967. by "IEEE Computer Society" award "National Medal of Science", year: 1975, by: "National Science Foundation" award "Turing Award", 1977, year by : "ACM" } 1. Find the list of researchers who were born before 1935? 2. Find the list of researchers who have received the "National Medal of Science" award since 1970. 3. Display only the last name and the first two contributions of all scientists. Sort the list in ascending order by the last name. 4. Find the list of researchers who are still alive. Limit the result set to 3 researchers. 5. Find all researchers who have made contributions to both "Fortran" and "Java". Part 2: Writing Advanced MongoDB Queries We have a collection of populations by postal code named "codes" (see the codes.json file). The postal codes are in the_id field, and are therefore unique. Documents look like this: { _id: "35045", city: "CLANTON", loc [-86.64, 32.84], pop: 13990, state : "AL" } Note that there are 50 non-overlapping states in the US with two letter abbreviations such as NY and CA. In addition, the capital of Washington is within an area designated the District of Columbia, and carries the abbreviation DC. For purposes of the mail, the postal service considers DC to be a "state." So in this dataset, there are 51 states. A city may overlap several postal codes. Write an aggregation query to answer the following questions. in the result set is used a placeholder for the correct answer. 6. Find the population of each state. The output should look like this: { { }, _id: "CA", population 7. Find the population of the postal code in each state with the highest population. The output should look like this: { }, _id: "MT", population state : "WI", population state "WV", population 8. Find the population of each city in the state of New York (NY) and list the postal codes that are included in each city. The output should look like this: { _id = "ELMIRA", population postal codes: [ ] population of ELMIRA>, } , , _id: "WHITESVILLE", population : , postal codes: [ ] 9. Find the largest city in each state. The output should look like this: { _id: "WI", city: , population _id: "VT", city: , population }, 10. Calculate the average population of cities in California (CA) and New York (NY) with populations over 30,000. The output should look like this: { pop ASSIGNMENT 4 Due Date: December 3, 2023 (11:59 pm) In this assignment, you will use MongoDB query language to read, process, and extract data from MongoDB collections. The first part of the assignment involves writing "simple MongoDB queries" using the find() method. The second part of the assignment involves writing "advanced MongoDB queries" using the MongoDB aggregation pipeline. For each question, your answer should be a single MongoDB statement (i.e., there should be a piece of code starting with db.collection.method() and ending with a semi-column). Save your answers to a text file. Do NOT forget to write your group number and the names of all the members in your group at the top the file using comment lines (/* Group x*/) (/* Member 1 Name*/) (/* Member 2 Name*/) Use a comment line to indicate which question the subsequent query answers (such as /*Answer to Question X*/). Submit a soft copy of your assignment (one submission per group) by the due date (refer to the class syllabus for late submission penalties). You can make only ONE attempt. Therefore, do NOT submit your assignment prematurely if you think that you can make changes on your solution later. Good luck! Part 1: Writing Simple MongoDB Queries We have a collection of researchers named "scientists" (see the scientists.json file). This collection keeps track of basic information about researchers, like their name, birth date, death date (if any), contributions to the scientific world, awards received for their contributions. Each document has a unique_id field and looks like this: { _id: 1, name: { first "John", last "Backus" }, birth ISODate("1924-12-03T05:00:00Z"), death ISODate("2007-03-17T04:00:00Z"), contribs [ ] "Fortran", "ALGOL", "FP" ], awards [ { { award: "W.W. McDowell Award", year: 1967. by "IEEE Computer Society" award "National Medal of Science", year: 1975, by: "National Science Foundation" award "Turing Award", 1977, year by : "ACM" } 1. Find the list of researchers who were born before 1935? 2. Find the list of researchers who have received the "National Medal of Science" award since 1970. 3. Display only the last name and the first two contributions of all scientists. Sort the list in ascending order by the last name. 4. Find the list of researchers who are still alive. Limit the result set to 3 researchers. 5. Find all researchers who have made contributions to both "Fortran" and "Java". Part 2: Writing Advanced MongoDB Queries We have a collection of populations by postal code named "codes" (see the codes.json file). The postal codes are in the_id field, and are therefore unique. Documents look like this: { _id: "35045", city: "CLANTON", loc [-86.64, 32.84], pop: 13990, state : "AL" } Note that there are 50 non-overlapping states in the US with two letter abbreviations such as NY and CA. In addition, the capital of Washington is within an area designated the District of Columbia, and carries the abbreviation DC. For purposes of the mail, the postal service considers DC to be a "state." So in this dataset, there are 51 states. A city may overlap several postal codes. Write an aggregation query to answer the following questions. in the result set is used a placeholder for the correct answer. 6. Find the population of each state. The output should look like this: { { }, _id: "CA", population 7. Find the population of the postal code in each state with the highest population. The output should look like this: { }, _id: "MT", population state : "WI", population state "WV", population 8. Find the population of each city in the state of New York (NY) and list the postal codes that are included in each city. The output should look like this: { _id = "ELMIRA", population postal codes: [ ] population of ELMIRA>, } , , _id: "WHITESVILLE", population : , postal codes: [ ] 9. Find the largest city in each state. The output should look like this: { _id: "WI", city: , population _id: "VT", city: , population }, 10. Calculate the average population of cities in California (CA) and New York (NY) with populations over 30,000. The output should look like this: { pop
Expert Answer:
Related Book For
Project Management The Managerial Process
ISBN: 9781260570434
8th Edition
Authors: Eric W Larson, Clifford F. Gray
Posted Date:
Students also viewed these databases questions
-
5) On the graphs below show the difference between a change in price and a change in demand. Fully label graphs for full marks! (2+2 marks) Change in price Change in demand X 6) A change in the price...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Several factors can impact the structural soundness of 3D-printed objects, including the struts that connect various pieces. The following data appears in the article Analyzing the Effects of...
-
Assuming there are 365 different birthdays, find the probability that of 20 people chosen randomly, (a) No two will have the same birthday. (b) At least two will have the same birthday.
-
Prove that E[b' b] = ' + 2Kk=1(1/k) where b is the ordinary least squares estimator and k is a characteristic root of X' X.
-
Verify the vector identity \[\begin{equation*}abla^{2} \boldsymbol{v}=abla(abla \cdot \boldsymbol{v})-abla \times(abla \times \boldsymbol{v}) \tag{15.83}\end{equation*}\]
-
The following tasks are completed by the auditor while observing the physical inventory. For each task, state which assertion(s) is tested by the task: (1) existence or occurrence, (2) completeness,...
-
Determine the roots of the following polynomials using MATLAB: P1(x) = x + 8x6 + 5x5 + 4x4 + 3x3 + 2x+x+1 P3(x)=x5-13x + 10x3 + 12x + 8x - 15
-
Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER (OwnerID, OwnerName, OwnerEmail, OwnerType) OWNED_PROPERTY (PropertyID, PropertyName,...
-
The Merchandising of a selling floor or a website is a very distinctive feature of a stores merchandise strategy. For this discussion I want you to get out to the stores and analyze the merchandise...
-
Discuss why graphical techniques for displaying plans are superior to verbal statements.
-
What happens to a constraining resource when it is required by more than one project at any one time? Which project should it be working on?
-
What is the evidence for student syndrome? How might you encourage people to move away from such behavior?
-
What is quality?
-
Where should buffers be placed? Using an example of a personal project, show how the use of a buffer would help.
-
Solve the initial value problem below using the method of Laplace transforms w"-4w' 4w= 201 + 44, w(-3) = - 1, w'(-3) = 6 Click here to view the table of Laplace transforms. Click here to view the...
-
Describe the general ways that the revised Form 990, applicable for tax year 2008 and beyond, is different from previous versions.
-
What is the difference between avoiding a risk and retaining a risk?
-
What aspects of the Arthur Andersen culture contributed to the scandal?
-
1 . How did Helmstetters vision conflict with USGA rules? 2 . How could this mistake have been avoided?
-
For each of the following sets of numbers, calculate a \(95 \%\) confidence interval for the mean ( \(\sigma\) known); before going through the steps in calculating the confidence interval, the...
-
Consider a 3 -year \(10 \%\) coupon bond. The underlying short rate of interest follows a lattice with initial value of \(R=1.15\) and then has an factor of 1.02 , a down factor of .99 , and...
-
Using the density function of the stopping time probability for a fixed \(\lambda\), find the average time to the first event over the entire interval \([0, \infty)\).
Study smarter with the SolutionInn App