A comprehensive Access database system for managing a smart gym, including memberships, workout plans, training sessions, progress tracking, and AI-powered recommendations.
This database implements a "Smart Gym" management system that goes beyond simple data storage. It includes:
- Membership Management: Track members, plans, subscriptions, and payments
- Workout Planning: Exercise library, workout plan templates, and plan-to-exercise mappings
- Training Logs: Detailed session tracking with granular set-by-set logging
- Progress Tracking: Body metrics, goals, and progress monitoring
- Smart Recommendations: AI-like recommendations based on training patterns
- Members: Member information and status
- MembershipPlans: Available membership tiers (Basic, Premium, PT Bundle)
- MemberMemberships: Subscription history (allows tracking multiple subscriptions per member)
- Payments: Payment records linked to memberships
- Exercises: Exercise library with muscle groups, equipment, difficulty
- WorkoutPlans: Template workout plans (Push/Pull/Legs, Full Body, etc.)
- PlanExercises: M:N relationship between plans and exercises (with targets)
- TrainingSessions: Actual workout sessions performed by members
- SessionExercises: Exercises performed in each session
- SetLogs: Granular tracking of sets, reps, weights, RPE, and PRs
- BodyMetrics: Weight, body fat, measurements over time
- Goals: Member goals (weight loss, strength targets, etc.)
- Recommendations: System-generated recommendations for members
- Members → MemberMemberships → Payments
- Members → TrainingSessions → SessionExercises → SetLogs
- Members → BodyMetrics, Goals, Recommendations
- WorkoutPlans → PlanExercises
- Exercises → PlanExercises, SessionExercises
- WorkoutPlans ↔ Exercises (via PlanExercises)
- TrainingSessions ↔ Exercises (via SessionExercises)
The database includes 9 pre-built views/queries:
- ActiveMembersWithPlan: Active members with their current plan and last payment
- MonthlyRevenueByPlan: Revenue breakdown by plan type and month
- ExpiringMemberships: Memberships expiring in the next 14 days
- ExercisePopularity: Most popular exercises by set count
- PRLeaderboard: Personal records achieved this month
- TrainingConsistency: Average sessions per week per member
- BodyMetricsProgress: Weight and measurement changes over time
- ActiveRecommendations: Recent recommendations for members
- GoalsProgress: Active goals with progress tracking
- Windows (Access database requires Windows)
- Python 3.10+
- Microsoft Access Database Engine (64-bit)
- Microsoft Access (for database creation, or use pywin32)
-
Install Python dependencies:
pip install -r requirements.txtOr manually:
pip install pyodbc pywin32
-
Run the build script:
python build.py
-
Output: The script will create
smart_gym.accdbin the project root directory.
The build.py script:
- Removes existing database (if present)
- Creates all tables from
schema/tables.sql - Loads seed data from CSV files in
seed/ - Creates foreign key relationships from
schema/relationships.sql - Creates views/queries from
schema/queries.sql
smart-gym-db/
│
├── build.py # Main build script
├── config.py # Database configuration
├── smart_gym.accdb # Generated Access database (after build)
│
├── schema/
│ ├── tables.sql # Table definitions
│ ├── relationships.sql # Foreign key constraints
│ └── queries.sql # Views and queries
│
├── seed/
│ ├── members.csv
│ ├── membership_plans.csv
│ ├── member_memberships.csv
│ ├── payments.csv
│ ├── exercises.csv
│ ├── workout_plans.csv
│ ├── plan_exercises.csv
│ ├── training_sessions.csv
│ ├── session_exercises.csv
│ ├── set_logs.csv
│ ├── body_metrics.csv
│ ├── goals.csv
│ └── recommendations.csv
│
├── utils/
│ ├── db.py # Database connection utilities
│ └── seed_loader.py # CSV data loader
│
├─ .github/
│ └─ workflows/
│ └─ build-access-db.yml
│
└── README.md
This database solves the problem of managing a modern gym that needs to:
- Track member subscriptions and payments over time
- Provide structured workout plans to members
- Log detailed training sessions (not just "worked out", but specific exercises, sets, reps, weights)
- Monitor progress through body metrics
- Set and track goals
- Generate intelligent recommendations (e.g., "increase weight", "deload", "add cardio")
- The database uses Access SQL syntax (AUTOINCREMENT, YESNO, etc.)
- Some advanced SQL features (window functions) may need adjustment for older Access versions
- Date functions use Access-specific syntax (DATEDIFF, DATEADD)
- The seed data includes realistic sample data for testing queries
Error: "Microsoft Access Driver not found"
- Install Microsoft Access Database Engine (64-bit) from Microsoft's website
- Ensure Python and Access Engine are both 64-bit or both 32-bit
Error: "win32com not available"
- Install pywin32:
pip install pywin32 - Or manually create an empty Access database file named
smart_gym.accdbin the project root, then run the script
Error: "Table already exists"
- The build script automatically removes existing database
- If issues persist, manually delete
smart_gym.accdbbefore running
Queries not working
- Some queries use Access-specific functions that may vary by version
- Test queries individually in Access if needed
Running on macOS/Linux
- This project requires Windows to create Access databases
- You can develop the code on any OS, but must run
build.pyon Windows - Consider using a Windows VM, Azure VM, or a friend's Windows computer for the final build