使用 PHP 和 MySQL 处理用户帐户使用情况
我正在构建一个应用程序,让用户拥有一个基本帐户,并且能够为其帐户购买更多使用量。例如,用户只能拥有 50mb 的数据,之后他们可以购买更多的数据......
我想知道的问题是如何将这些信息存储在表中以及如何管理他们的当前使用情况和当前限制。最好将此信息存储到单个表中,例如:
Usage
-------------------
id
user_id
mb_used
mb_limit
xx_used
xx_limit
etc
那么我是否会在他们订购更多兆字节等时更新限制?我考虑过预定的包,但对于这个应用程序来说这是不可接受的。
如果您需要更多信息来提供更好的指导,请告诉我。
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于兆字节,平坦的表就可以了。详细解释一下您的桌子,我可以为您提供进一步的帮助。
现在我将仅列出使用单表架构时的一些注意事项。
对于一张表来说版本控制和历史记录是很困难的。如果一个人想要查看他们购买了多少个 meg 的历史记录,会发生什么?
表的访问速度 - 取决于您的应用程序的工作方式 - 是否有更多的插入然后选择? mb 字段的访问频率是否比“xx”字段更频繁?拆分表可以提高速度
您还可以使用平面文件表并仍然执行版本历史记录。
我想这取决于你想做什么。
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: