Reference no: EM133626520
Overview
In this milestone, you will import the Austin Animal Center (AAC) CSV file that you will be using for Project One into MongoDB. You will then form both a single and a compound index to optimize the queries for the scenario. Remember that you can use the explain function to verify the use of indexes in your queries. Finally, you will create a user account in Mongo to address security needs (your mongodb instance in Apporto already operates with an admin account).
Note: Every time you connect to your Apporto environment, your MongoDB server will automatically start up, usually within about 2 minutes of your login. The MongoDB instance always starts with the authentication enabled.
Be sure to begin working on your milestone early in the week. One natural stopping point would be after finishing Part I.
Prompt
Part I: Importing and Indexing a Data Set
You have been asked to import a file for the Grazioso Salvare project. In order to do so, you must complete the following steps:
You have been asked to import a file for the Grazioso Salvare project. You must perform the following steps to do so:
In Apporto, open the terminal window to access the Linux shell. Upload the Austin Animal Center (AAC) Outcomes data set into MongoDB by importing a CSV file using the appropriate MongoDB import tool. Use the database name "AAC" and collection name "animals." Complete the import using the mongoimport tool, and take screenshots of both the import command and its execution.
Tip: How to import a CSV file is covered in the mongoimport documentation in the Module Three Resources Additional Support section. The command you use should be like the ones used in Module One Assignment and Module Two Assignment. (The requirements and rubric documents contain examples for the mongoimport command, but these use the default JSON datatype; adjust the command to import a CSV file.) You'll find the Austin Animal Center (AAC) Outcomes data set in the /usr/local/datasets/ directory. The file name is "aac_shelter_outcomes.csv".
After importing your data set, open the mongo shell. -Create a simple index on the key "breed." Show an example query using this index, and use the explain function to verify that the index will be used. Take screenshots of your example query.
-Create a compound index that will improve the performance of queries looking for breeds that have an "outcome_type" of "Transfer." Show an example query using this compound index, and use the explain function to confirm the index will be used. Take screenshots of your example query.
Part II: User Authentication
The client has asked you to comply with their security needs and ensure user authentication to the database by setting up both administrator and user accounts. Your administrator account has already been configured on your database in Apporto. So, you will only have to create a user account. To do so, follow the steps below.
-Create a new user account called "aacuser" for the database AAC in the mongo shell. Refer to steps 6-7 of the MongoDB Manual Enable Access Control tutorial for help with this task. You will need to modify the commands so the account name is "aacuser." Additional information with respect to user management may be found in the User Management in MongoDB document.
Note: You will need to create your user in the admin database, even though it will only have a role in the aac database. When you use the mongo shell (mongosh) to connect to the database with your user account, you will need to reset two environment variables to reflect the username and password you just created. (The MongoDB hostname and port will be pulled automatically from your environment variables.)
Tip: To make it easier to log in as your user, open up a second terminal session in your Linux environment. In this session, set the following environment variables:
Once this is complete, you can run mongosh in that window as your new user.
Example:
IMPORTANT: Write down the password for the aacuser account and keep it handy. You will need to use this account later in the course.
Take a screenshot of your login process to MongoDB using the mongo shell. Be sure you can access MongoDB and list the databases using both the admin and aacuser accounts. This task will verify that your accounts are working. You should be able to include the login commands for both accounts in one screenshot, but if you cannot, include two screenshots to show both login commands.
When you have successfully attached to your MongoDB instance with mongosh, use the following command to verify that you have connected as a specific user:
Include the results in your screenshot for each user.