开发者

Handling user account usage with PHP and MySQL

I'm building an application that'll let users have a basic account with the ability to buy more usage for their account. For example, a user can only have 50mb of data after which they can buy more among other things...

The issue I'm wondering about is how to store this information in a table and how to manage their current usage and their current limits. Would it be best to store this information into a single table such as:

Usage
-------------------
id
user_id
mb_used开发者_如何学编程
mb_limit
xx_used
xx_limit
etc

Then would I just update the limit as they order more megabytes etc? I've thought about predetermined packages, but for this application it would not be acceptable.

Let me know if you need more information to give better guidance.

Thanks!


For megabytes, a flat table will be fine. Explain more about your table and I could help you further.

For now I'll just list some considerations when using a single table architecture.

Versioning and history is difficult with one table. What happens if a person wants to look at a history of how many megs that they have purchased?

access speeds to the table - depending on how your application works - are there more inserts then selects? are the mb fields accessed more often than the "xx" fields? splitting the table up can increase the speed

You could also use a flat file table and still perform version history.

I guess it depends on what you want to do.


if it is a report table - like snapshot after each or daily operation on the account:

Usage:

  • id
  • user_id
  • mb_used
  • mb_limit
  • timestamp
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜