Learning PHP/MySQL -- a database design question

Learning PHP/MySQL -- a database design question

by Tim Wilson -
Number of replies: 1

Having been inspired to learn PHP and MySQL by Moodle's elegant design, I've finally found something that I'd like to use as my first PHP project. I've got a couple ideas for Moodle modules too, but this particular itch needs more scratching at the moment. smile

I've just started a jogging regimen and it occurs to me that a PHP/MySQL version of a fitness tracker would make a nice little project. (It's been done before, of course, but I think it would still be a nice project for me.) If anything comes of it, I plan to make it available on my school district's intranet for other staff to use. With that in mind, I've come up with the following basic requirements:

  • Multi-user capability. Should have the ability for many user accounts while maintaining some basic privacy for each user.
  • Log periodic fitness measures such as weight, blood pressure, % body fat, etc. The user would enter this information as often as he or she desires to create a record or weight loss, for example.
  • Workout records. Users should be able to enter information about their workouts. Should support multiple types of workouts including bike rides, runs/walks, swims, tennis matches, etc. Each workout type would have its own specific types of data. Runs, for example, might track distance, time, average heart rate (if the user has a heart rate monitor), and a note field. (Lots more fields are possible.)
  • Saved "routes". If a particular user runs or bikes the same route frequently or does the same workout often, they could attach a workout's results (time, heart rate, etc.) to a particular "route" that would allow them to track their progress over time on a particular route.

I'm stuck on a particular step of the database design. I should point out that I'm not completely new to this. I built an event calendar application for my former school district using Zope and PostgreSQL. Here's the major question I've got:

How do I allow for more workout types to be added and relate them to the existing tables?

I can imaging have tables for users, daily_stats, workouts, and routes, but how would I integrate new workout types? I don't think adding fields to a general workout table would be the most elegant solution. Maybe I'm wrong. (It's happened before.) smile

Does anyone have any thoughts on this?

Average of ratings: -
In reply to Tim Wilson

Re: Learning PHP/MySQL -- a database design question

by Tim Wilson -
I should add, by the way, that I'm going to use this project to get to know the Moodle code since there are components of this system (e.g., user login) that are nearly the same as Moodle.