175|SQL&CHATGPT – Shelter Shenanigans Again

Millie_K_B
Tue, 09 Apr 2024 23:45:42 +0000
Challenges

BYU Student Author: @Millie_K_B
Reviewers: @jimmy_han, @Sterling_Lane
Estimated Time to Solve: 60 Minutes

We provide the solution to this challenge using:

SQL

ChatGPT 3.5

Need a program? Click here.

Overview
This challenge is correlated with 173|SQL – Shelter Shenanigans and 171|SQL – Shelter Shenanigans Sequel. It is not necessary to complete either challenge before completing this one, although doing so will increase your familiarity with the database.

You’re still waiting on the call from your dream job and volunteering at the animal shelter in the meantime. During your time there, you’ve noticed that the existing database lacks certain data and functionality. For example, there’s no straightforward way to determine if an animal is a dog, cat, or rabbit. You remember when your boss asked for information on all the rabbits, and you had to sift through the database to find the rabbit breeds and filter the data accordingly. Fortunately, there were only two rabbit breeds, but you shudder to think of doing the same kind of analysis for all the dog breeds.

With these database issues in mind, you write a to-do list and grab a Pepsi. Today, you will add the data needed for future questions you anticipate getting from your boss.

Instructions
We will be adding our own newly generated data to the database. Since this data is randomly generated, your results will vary from the provided solution file, but your database structure should be identical with correctly established relationships. You may use ChatGPT or any other generative AI program. Thiis challenge will reference ChatGPT 3.5 as that is what was used to create the solution. You may also use whatever SQL software you feel comfortable using. If you choose to use something other than Access, there is an Excel spreadsheet provided for you to use.

1. First on the list is sorting all the animals by dog, cat, or rabbit. Since you don’t know which breeds belong to which type of animal, use ChatGPT to generate this information.
a. You may pick one of two options to include this data in the database. The first option is to create a new table, AnimalBreeds, with all of the breeds and what type of animal each breed is, then use a primary/foreign key set to connect the Animals table with the AnimalBreeds table. The second option is to add a new column to the Animals table to record AnimalType. The solution will show the second option.
b. There is a breed type, “Mixed Breed,” that will only refer to dogs.
c. As it turns out, this was incredibly important to accomplish first. A wealthy donor just called the Central location and offered to pay the adoption fees of all the dogs there, and you need to let the donor know how much it will cost them. Use an SQL query to find the sum of all the adoption fees for dogs at the Central location.

2. With that handled, you move to the next task on your list. There currently is no way to track the shelters’ volunteers!
a. Each location should have at least two assigned volunteers. Available hours should range from 5 to 15 and start dates should fall in the same range as Employee hire dates.
b. Also create a primary key based on each volunteer’s start date, so that the first volunteer to start has VolunteerID 201. This way, the volunteer IDs will be visibly different from the employee IDs, which start at 101.
c. Be sure to define relationships between your new Volunteer table and existing tables as needed.

Generate a volunteer table with 14 rows and the following column names:

First_Name

Last_Name

LocationID

Available_Hours

Start_Date

Phone_Number

3. After adding the Volunteer table, you realize the Employee table does not include phone numbers. Generate the correct number of phone numbers and add a phone number column to the Employee table. Make sure there are no duplicate phone numbers.
a. If you’d like extra practice, consider what other information would be useful to have in the Employee table, such as wage data or certification types, and generate and add the data. Some of these types of data would be best entered as separate tables, joined to the Employee table with foreign keys. ChatGPT could give you ideas on what information to add.

4. While working with the Employee table, you notice that no one has updated the table since Chloe Martin left.
a. Remove Chloe Martin’s employee information, making note of her role and LocationID before doing so, as it will be needed for her replacement.
b. Add a row for her replacement, Janis Morgan. She was hired on March 28, 2024, and her employee ID will be the next sequential number in the employee ID column.

Data Files

Challenge175_Data.accdb

Challenge175_Data.xlsx

Challenge175_Data_Dictionary

Suggestions and Hints (click for more details)
Solution

spoiler

3 posts - 3 participants