douxi2011
douxi2011
2014-01-02 01:30

PHP / MySQL程序大纲

已采纳

I'm currently in the process of creating a website and want to know how you guys think I should go about storing my information.

I'm making a website which allows users to create an account and then enter/log in workout information each day that they can.

Each time they input a log, there are a few pieces of information they must include (ie. the date, the length of their workout, the type of workout, etc.). The website will then be able to supply them with graphs that analyze their data.

I'm coding using php and mysql. My question revolves around how I should store all the data for the website. I know I need a mysql table that will have a column for id, username, email, and password. However, I'm unsure how to store the daily logs.

Should I create an array for each field (ie. workout duration) and use serialize() to store it in the same table as the users? If so, how would I go about updating the array each time a log is inputed? Thanks.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dongmo6937 dongmo6937 7年前

    I would suggest to use several tables for this, for example the tables:

    • site_users
    • site_workouts

    That way you have all user data stored separately. In your workouts table, you would add a new row per record, and include a foreign key (user_ID) that links each row to a user. So you could match a list of workout logs to a single user.

    点赞 评论 复制链接分享
  • dongzhi2014 dongzhi2014 7年前

    It's your choice but personally I would use 2 sql tables:

    User(id, username, email, and password) Workout(user_id, date, workout_length, workout_type)

    This way you can keep adding logs for users and recieve the data when needed. You keep comptibility with alot of other services.

    And process the sql records with php.

    点赞 评论 复制链接分享

相关推荐