For this project, I am creating a unique scenario in which a database is designed, and a series of SQL commands are performed to demonstrate my proficiency in database management and SQL.
The scenario revolves around Purrs-R-Us, a hypothetical cat shelter that also operates a supply shop to support its operations. The shop's revenue helps fund the care of the cats awaiting adoption. To boost engagement and sales, the shelter has introduced a program offering discounts to customers who adopt cats, encouraging them to purchase supplies from the shop. This initiative is also designed to increase adoption rates by integrating the shop and shelter experience.
This project demonstrates:
- Database creation and normalization.
- Mechanisms for automation and data-driven decision-making, such as:
- SQL Transactions
- SQL Procedures
- SQL Triggers
- SQL Views
- Solutions for improving processes and understanding customer behaviour.
To ensure efficiency and eliminate redundancy, the database adheres to the following normalization standards:
- Each table has a primary key, and all columns contain atomic values.
- Example: In the customer_contact table, City and Street are stored in separate columns.
- Non-key columns depend entirely on the primary key, avoiding partial dependencies.
- Example: Customer details are stored in a customers table, separate from the cats table, despite their relationship.
- Non-key columns are not transitively dependent on the primary key.
- Example: shop_orders and item_prices are kept separate to avoid dependency conflicts.
- Functional dependencies between non-key attributes are eliminated.
- Example: In the cats table, cat_id determines owner_id, but since customers can own multiple cats, dependencies are managed separately.
- Multi-valued dependencies are removed. None of the tables have columns partially dependent on a composite primary key.
- Complex many-to-many relationships are decomposed into smaller tables.
- Example: An enhanced table consolidates data for user comprehension while maintaining normalized relationships across tables.
Challenge: Cashiers manually check item IDs, promotions, and calculate discounts, leading to inefficiencies.
Solution:
-
An SQL procedure that allows sales orders to be input with user-friendly parameters (e.g., item descriptions).
-
A trigger that automatically:
-
Populates enhanced order details.
-
Calculates order totals, discounts, and eligibility for promotions.
-
Challenge: Manual stock verification caused unexpected shortages.
Solution:
-
Procedures are implemented to verify stock availability during order processing.
-
Stock levels are automatically adjusted for successful orders.
Challenge: Overwhelming information in the shop_orders_enhanced table.
Solution:
- A user-friendly view displays essential transaction details while omitting unnecessary fields.
Challenge: Adding new customers delayed transaction processing.
Solution:
- New customers are automatically added to the customer table during order entry.
Challenge: The sales team wanted to identify the top six spenders monthly.
Solution:
- A view displays top customers with total spend, their preferred item categories, and category contribution percentages.
Challenge: Targeted campaigns required data on non-adopted cats and customer behaviour.
Solution:
- Queries provide:
- Most frequent fur coloUrs among adopted and non-adopted cats.
- Average ages within cat breeds.
- Lists of customers with and without adopted cats.
Challenge: Identifying customers who purchased a recalled product.
Solution:
- Queries retrieve customer and transaction details for communication and refunds.
Challenge: Customers requested selective removal of contact information.
Solution:
- A procedure that removes contact details without exposing other customer data.
- A query that ensures the integrity of the customer and customer_contact tables.
- Screenshots of tables (before and after processes) are provided.
- Images are sequentially numbered and correspond to the order of the SQL code.
This project successfully demonstrates my SQL skills, including database normalization, procedure creation, automation, and data-driven insights. By addressing practical challenges faced by Purrs-R-Us, the project showcases the ability to design scalable and efficient database solutions tailored to real-world scenarios.