A complete PostgreSQL database for an e-commerce platform with realistic data and 20+ analytical queries.
- 5 Normalized Tables: Users, Products, Categories, Orders, Order Items
- Realistic Sample Data: 100+ records across all tables
- 20+ Analytical Queries: From basic to advanced business intelligence
- Performance Optimized: Proper indexes and constraints
- Abandoned Cart Analysis: Specialized e-commerce analytics
- Customer Segmentation: RFM analysis and behavior tracking
- users - Customer information
- products - Product catalog with inventory
- categories - Hierarchical product categories
- orders - Customer orders with status tracking
- order_items - Line items for each order
- cart_items - Shopping cart data (for abandoned cart analysis)
- Create a Neon account at neon.tech
- Create a new project called
ecommerce-db - Copy your connection string
- Run the setup script:
# Make the setup script executable
chmod +x scripts/setup_database.sh
# Run the setup (update with your Neon connection string)
./scripts/setup_database.sh "your_neon_connection_string"
#Manual Setup:
```bash
-- 1. Create tables
\i database/schema/01_create_tables.sql
-- 2. Create indexes
\i database/schema/02_create_indexes.sql
-- 3. Insert sample data
\i database/data/01_insert_categories.sql
\i database/data/02_insert_users.sql
\i database/data/03_insert_products.sql
\i database/data/04_insert_orders.sql
\i database/data/05_insert_cart_items.sqlThe project includes 4 categories of queries:
- Simple SELECT statements
- Basic JOIN operations
- Filtering and sorting
- Revenue analysis by category
- Customer segmentation
- Product performance
- Sales trends
- Customer Lifetime Value (CLV)
- Product affinity analysis
- Inventory turnover
- Cohort analysis
- Executive dashboard
- Monthly performance reports
- Abandoned cart analysis
- Inventory restock alerts
- VIP customers (> $2000 spent)
- Regular customers ($500-$2000)
-Occasional customers (< $500)
- Electronics leads with 45% of revenue
- Furniture has highest average order value
- Clothing has highest unit sales
- 12% cart abandonment rate
- $2,500+ in potential lost revenue
- Most abandoned items: Electronics
Run test queries to verify setup:
-- Test data integrity
\i tests/test_queries.sql
-- Compare with expected results
cat tests/expected_results.md