Expand to Business Analytics: Add Customer, Sales, and KPI models

Major expansion from fraud detection to comprehensive business analytics:

DATABASE CHANGES:
- Renamed database from 'fraud_detection' to 'business_analytics'
- Renamed user from 'fraud_analyst' to 'data_analyst'
- Expanded from 20 to 39 tables across 4 business models

NEW MODELS (19 tables):
1. Customer Analytics (5 tables):
   - customer_segments, customer_lifetime_value, churn_predictions
   - customer_satisfaction, engagement_metrics

2. Sales & Revenue Analytics (6 tables):
   - product_catalog, sales_transactions, sales_targets
   - sales_performance, revenue_forecasts

3. KPI & Metrics (8 tables):
   - kpi_definitions, daily_metrics, monthly_summaries
   - trend_analysis, dashboard_snapshots
   - report_definitions, report_executions, data_quality_checks

DATA GENERATION:
- Extended generate_data.sh with 6 new steps (now 15 total)
- Added CLV calculations for all customers
- Added churn predictions based on transaction recency
- Added 30K customer satisfaction surveys
- Added 1M sales transactions linked to 24 products
- Added 90 days of daily KPI metrics
- Added 24 months of business summaries

SQL EXERCISES (3 new levels):
- Level 2: Customer Analytics (10 exercises + 3 challenges)
- Level 3: Sales & Revenue Analysis (12 exercises + 3 challenges)
- Level 4: KPI Dashboards & Metrics (12 exercises + 3 challenges)

DOCUMENTATION:
- Updated README.md with business analytics focus
- Updated QUICKSTART.md with new data generation steps
- Updated SETUP_COMPLETE.md with 39-table architecture
- Added DATA_MODELS.md with complete model specifications
- Added WHATS_NEW.md with migration guide

SEED DATA:
- Added 8 customer segments (VIP, High Value, etc.)
- Added 24 products across 5 categories
- Added 16 KPI definitions across 4 categories
- Added 8 standard report definitions

All changes maintain idempotency and backward compatibility with existing fraud detection functionality.
This commit is contained in:
Alphaeus Mote
2025-10-23 14:17:12 -04:00
parent b30733ccad
commit aa803bd3bd
14 changed files with 2762 additions and 132 deletions
+31 -5
View File
@@ -1,4 +1,4 @@
# 🎉 Financial Fraud Detection Database - Setup Complete!
# 🎉 Business Analytics Database - Setup Complete!
## ✅ What Has Been Created
@@ -9,9 +9,11 @@
- ✅ Persistent volumes for data
- ✅ Health checks and auto-restart
### 2. **Database Schema (20+ Tables)**
### 2. **Database Schema (39 Tables Across 4 Business Models)**
#### Core Tables
#### Model 1: Fraud Detection (20 tables)
**Core Tables:**
-`customers` - 100K customer records with KYC data
-`accounts` - 150K bank accounts (checking, savings, credit)
-`cards` - 200K payment cards
@@ -19,13 +21,13 @@
-`merchants` - 50K merchants across 35 categories
-`devices` - 75K device fingerprints
#### Fraud Detection Tables
**Fraud Detection Tables:**
-`alerts` - System-generated fraud alerts
-`fraud_cases` - Confirmed fraud investigations
-`case_transactions` - Links transactions to cases
-`case_alerts` - Links alerts to cases
#### Supporting Tables
**Supporting Tables:**
-`countries` - 40 countries with risk levels
-`merchant_categories` - 35 MCC categories
-`transaction_types` - 15 transaction types
@@ -37,6 +39,30 @@
-`suspicious_activity_reports` - SAR filings
-`audit_log` - Complete audit trail
#### Model 2: Customer Analytics (5 tables) ⭐ NEW
-`customer_segments` - Customer classification (VIP, High Value, etc.)
-`customer_lifetime_value` - CLV calculations for all customers
-`churn_predictions` - Customer retention risk analysis
-`customer_satisfaction` - NPS/CSAT scores and feedback
-`engagement_metrics` - Customer interaction tracking
#### Model 3: Sales & Revenue Analytics (6 tables) ⭐ NEW
-`product_catalog` - 24 products across categories
-`sales_transactions` - 1M sales records linked to products
-`sales_targets` - Performance goals and targets
-`sales_performance` - Aggregated performance metrics
-`revenue_forecasts` - Revenue predictions and variance
#### Model 4: KPI & Metrics (8 tables) ⭐ NEW
-`kpi_definitions` - Master KPI catalog (16 KPIs)
-`daily_metrics` - Daily operational snapshots (90 days)
-`monthly_summaries` - Monthly business summaries (24 months)
-`trend_analysis` - Statistical trend tracking
-`dashboard_snapshots` - Pre-calculated dashboard data
-`report_definitions` - Standard report catalog
-`report_executions` - Report run history
-`data_quality_checks` - Data validation tracking
### 3. **Realistic Geographic Data**
- ✅ 100 US cities with matching states
- ✅ 210 world cities across 40 countries