Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Overview You must learn various techniques for the fundamental operations of Create, Read, Update, and Delete ( CRUD ) to understand and benefit from any
Overview
You must learn various techniques for the fundamental operations of Create, Read, Update, and Delete CRUD to understand and benefit from any database system. You will begin this assignment by creating databases of document collections and performing basic reading or querying operations to retrieve specific documents from the database system. You will also gain practice updating documents and subdocuments, and removing documents from a database. You will use the mongo shell and mongoimport commands to complete this assignment.
Note: This assignment is the only one for Module Two, so it is longer than a typical assignment. Be sure to begin working on it early in the week.
Prompt
After completing the textbook reading and reviewing the mongoimport tool documentation in the module resources, perform the following tasks using the mongo shell in Apporto.
Access the dataset for this assignment, cityinspections.json, in the usrlocaldatasets directory in your Apporto environment. Using the mongoimport tool and documents found in the cityinspections.json file, load the database city into the inspections collection. Complete this task by typing the following commands in the Linux terminal to perform the import in the right directory:
Change into the Apporto directory with the data sets:
cd usrlocaldatasets
Use the mongo import utility to load the data set:
mongoimport username$MONGOUSER
password$MONGOPASSport$MONGOPORT
host$MONGOHOSTdb city collection inspections
authenticationDatabase admin drop cityinspections.json
Tip: In any Linux systems, commands must be exact and use proper syntax and case sensitivity
Verify your load by using the city database, and issuing the following queries in the mongo shell:
dbinspections.findid : ENFO"
dbinspections.findresult:"Out of Business"businessname":limit
Provide screenshots of the results as evidence.
Using the appropriate commands in the mongo shell, insert a document to the database named city within the collection named inspections Use the following keyvalue pairs as data for your document.
Key Value
id ACME"
certificatenumber
businessname "ACME Explosives"
date Today's date
result "Business Padlocked"
sector "Explosive Retail Dealer
address
number
street Boom Road
city BRONX
zip
Be sure to insert the address as a subdocument and use the JavaScript function Date for Todays date. Verify your database creation and insertion using the findOne function in the mongo shell. Provide a screenshot as evidence.
Answer the following questions using MongoDB queries.
What is the distinct list of inspection sector in the current inspections collection? How many are in the list? Do not count by hand.
What is the difference in the date data type for the business named AUSTIN versus your business document insertion of Acme Explosives
How many businesses have a Violation IssuedSee Value column above.
Verify by providing screenshots of the queries and results as evidence.
Using the appropriate command in the mongo shell, update the document with the ID ACME in the collection inspections in the database city with the information below.
Key Value
businessname "New ACME Flowers"
Result "Business Reopened
comments "Flowers after the explosion"
Verify your database update using the appropriate find function in the mongo shell. Provide a screenshot as evidence.
Using the database city with documents found in the inspections collection, perform the tasks listed below. Verify by providing screenshots of the results as evidence.
Update all the documents that contain the keyvalue pair "city":"ROSEDALE" in the address subdocument by changing the zip code in the address subdocument to
Remove the first document with the keyvalue pair "result":"Violation Issued."
What to Submit
Submit a Word document containing all your screenshots. Use a screenshot tool, such as the Snipping Tool, and be sure to enlarge the images in the Word document before submission. Doing so will ensure that your screenshots are big enough for your instructor to read them. Refer to this Use Snipping Tool to Capture Screenshots guide for help with taking screenshots.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started