Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Competencies In this project, you will demonstrate your mastery of the following competencies: Apply database systems concepts and principles in the development of a client/server

Competencies

In this project, you will demonstrate your mastery of the following competencies:

Apply database systems concepts and principles in the development of a client/server application

Create a database that can interface with client-side code

Scenario

You work for Global Rain, a software engineering company that specializes in custom software design and development. Your team has been assigned to work on a project for an innovative international rescue-animal training company, Grazioso Salvare. You have been made the lead developer on this project.

As part of its work, Grazioso Salvare identifies dogs that are good candidates for search-and-rescue training. When trained, these dogs are able to find and help to rescue humans or other animals, often in life-threatening conditions. To help identify dogs for training, Grazioso Salvare has reached an agreement with a non-profit agency that operates five animal shelters in the region around Austin, Texas. This non-profit agency will provide Grazioso Salvare with data from their shelters.

In meeting with the client, Grazioso Salvare, you have discovered that they look for certain profiles in dogs to train. For instance, search-and-rescue training is generally more effective for dogs that are no more than two years old. Additionally, certain breeds of dogs are proficient at different types of rescue, such as water rescue, mountain or wilderness rescue, locating humans after a disaster, or finding a specific human by tracking their scent.

Grazioso Salvare is seeking a software application that can work with existing data from the animal shelters to identify and categorize available dogs. Global Rain has contracted for a full stack development of this application that will include a database and a client-facing web application dashboard, through which users at Grazioso Salvare will access the database. The full stack development will be fully completed in Projects One and Two.

Grazioso Salvare has also requested that the code for this project be open source and accessible on GitHub, so that it may be used and adapted by similar organizations. To that end, they have asked that you also create a README file to accompany your work.

In Project One, you will complete the first phase of this development by creating a database in MongoDB that can interact with client-side code. You will also create an initial README file to accompany your code. In Project Two, later in this course, you will complete the second phase of development by updating the database, producing the dashboard, and updating the README file to explain the full stack development.

Directions

Database Commands and CRUD Python Module

For your work on Project One, you will incorporate two previously completed milestones. First is the indexing for optimizing queries and authentication for database security, which you completed in the Module Three Milestone. Second is the CRUD (Create, Update, Read, and Delete) functionality for the animal database, which you began in the Module Four Milestone and will complete in this project.

You have been asked to create a database for the Grazioso Salvare project that is able to interface with client-side code. In order to do so, you must complete the following:

Upload the Austin Animal Center Outcomes data set into MongoDB by inserting a CSV file using the appropriate MongoDB import tool. The data set is located in the Supporting Materials section. Complete the import using the mongoimport tool and take screenshots of both the import command and its execution. These screenshots will later be included in your README file. Note: If you completed the Module Three Milestone, you have already completed this step. Be sure to include your screenshots from the Module Three Milestone in your README file.

Create an administrator account and a user account in the mongo shell to ensure user authentication to the database and collection that was created. Be sure to take a screenshot of the mongo shell execution command screen that shows your login process with both accounts. This screenshot will later be included in your README file. Note: If you completed the Module Three Milestone, you have already completed this step. Be sure to include your screenshots from the Module Three Milestone in your README file.

Next, you must develop a Python module in a PY file, using object-oriented programming methodology, to enable CRUD functionality for the database. To support code reusability, your Python code needs to be importable as a module by other Python scripts. Develop a CRUD class that, when instantiated, provides the following functionality:A Create method that inserts a document into a specified MongoDB database and collection

Input -> argument to function will be a set of key/value pairs in the data type acceptable to the MongoDB driver insert API call.

Return -> True if successful insert, else False.

A Read method that queries for document(s) from a specified MongoDB database and specified collection

Input -> arguments to function should be the key/value lookup pair to use with the MongoDB driver find API call.

Return -> result in cursor if successful, else MongoDB returned error message.

An Update method that queries for and changes document(s) from a specified MongoDB database and specified collection

Input -> arguments to function should be the key/value lookup pair to use with the MongoDB driver find API call. Last argument to function will be a set of key/value pairs in the data type acceptable to the MongoDB driver insert API call.

Return -> result in JSON format if successful, else MongoDB returned error message.

A Delete method that queries for and removes document(s) from a specified MongoDB database and specified collection

Input -> arguments to function should be the key/value lookup pair to use with the MongoDB driver find API call.

Return -> result in JSON format if successful, else MongoDB returned error message.

As you develop your code, be sure to use industry standard best practices such as proper naming conventions, exception handling, and in-line comments. This will ensure that your code is easy to read and reusable for future projects. Refer to the Python Style Guide, located in the Supporting Materials section, to help with these industry standard best practices. Note: If you completed the Module Four Milestone, you have already developed the Create and Read functionality.

Finally, you must test your Python module to make sure that it works. To do this, create a Python script that imports your CRUD Python module to call and test all instances of CRUD functionality. This script should be created in a separate Jupyter Notebook (IPYNB) file, and should import and instantiate an object from your CRUD library to effect changes in MongoDB. Be sure to use the username and password for the aacuser account for authentication when instantiating the class. After creating your script, execute it in Jupyter Notebook and take screenshots of the commands and their execution. These screenshots will later be included in your README file. Note: If you completed the Module Four Milestone, you have already begun this work. Expand your script to call and test the Update and Delete functionality.

README File

Grazioso Salvare has requested documentation to accompany the CRUD Python module. This will ensure that they are able to understand the work that was completed. It will also help them maintain the code for the database.

To document this project, you must create a README file that includes the following:

An explanation of the purpose of the CRUD Python module

An explanation of how the module should be used, including:

A description of the Python driver for Mongo that was used and why it was chosen

An explanation of the attributes and working functionality of the CRUD operations

A demonstration of the modules functional operations, including:

Screenshots of the MongoDB import execution. You took these screenshots in Step 1.

Screenshots of the user authentication execution. You took these screenshots in Step 2.

Screenshots of the CRUD functionality test execution. You took these screenshots in Step 4.

Note: If you completed the Module Four Milestone, you have already begun work on your README file. You will need to add more information to complete your README file and fully document your work in Project One.

What to Submit

To complete this project, you must submit the following:

Database Commands and CRUD Python Module

Submit the IPYNB and PY files containing your code for the project. This includes the Python module that you developed to enable all CRUD functionality and the Python script that calls that functionality. All code files should follow industry standard best practices, including well-commented code.

README File

Your submission should be a Word (DOC or DOCX) file containing an explanation of the Python module that you developed to enable CRUD functionality. In your README file, be sure to include all required screenshots.

Animal_shelter.py

from jupyter_plotly_dash import JupyterDash import dash_core_components as dcc import dash_html_components as html import dash from dash.dependencies import Input, Output import json import uuid import urllib.parse

from pymongo import MongoClient from bson.json_util import dumps

# Python CRUD Class for pymongo class AnimalShelter(object): """ CRUD operations for Animal collection in MongoDB """

def __init__(self, username, password): # Initializing the MongoClient using the specified path to my port # access the MongoDB databases and collections. self.client= MongoClient('mongodb://localhost:29840') #init connect to mongodb with authentication #self.client = MongoClient('mongodb://%s:%s@localhost:29840'%(username, password)) #Setting the AAC database to be worked from self.database = self.client['AAC'] # Create method to insert docuemnt into the collection def create(self, data): try: self.collection.insert_one(data) return True except: return False #Read method that queries for document(s) from a specified MongoDB database and specified collection def read(self, query): try: result = self.collection.find(query) return result except Exception as e: return str(e) #An Update method that queries for and changes document(s) from a specified MongoDB database and specified collection def update(self, query, data): try: self.collection.update_many(query, {'$set': data}) return True except Exception as e: return str(e)

#A Delete method that queries for and removes document(s) from a specified MongoDB database and specified collection def delete(self, query): try: self.collection.delete_many(query) return True except Exception as e: return str(e)

test_Script.py

from mongo_crud import AnimalShelter # Test cases for sample input and output # Create a class object with database name and collection name sample = CRUD("animalShelter","animals")

# Insert a sample records using create method animal = [{"name":"Stephen","species":"Dog"},{"name":"rocky","species":"cat"}] # Print the returned output for your reference print(sample.create(animal))

# Now read using read command read_test = sample.read({"species":"Dog"}) # print the cursor object returned by read command print(read_test) print(" ") print("Data from cursor") # Print the data from the cursor for data in read_test: print(data)

# Update elements using update updateElephantName = sample.update({ "species":"Dog" },{ "$set":{"name":"bob"} }) print("Objects that got updated ") print(updateDogName)

# Now delete all Dog using delete command deleteDog = sample.delete({ "species":"dog" }) print("Dog in collection after deleting all Dog ") print(deleteDog)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

Describe the three parts of developing a new habit.

Answered: 1 week ago