存储经常变化的数值时的数据库冗余

发布于 2024-09-03 19:22:21 字数 196 浏览 2 评论 0原文

对于我的下一个应用程序,用户可能会有许多不断变化的“点”。例如,用户可能会因执行任务而累积一定数量的积分、被取消积分或将积分捐赠给他们。

我想知道除了“历史”表(其中包含每个用户的点数的增量和减量)之外是否存储该值并不断更新它,或者除此之外在需要时计算用户的当前点数历史表。

显然,存储这个值会带来冗余,但可能比从历史表中的多行计算数百次点更好。

For my next app, users will likely have a number of 'points' which changes constantly. For example, a user might accrue a number of points for performing a task, have points taken away, or have points donated to them.

I'm wondering whether to store that value and update it constantly in addition to a 'history' table (which would contain the increments and decrements in points per user), or to calculate a user's current number of points when needed in addition to this history table.

Obviously having this value stored presents redundancy, but would perhaps be preferable to calculating points from multiple rows in the history table hundreds of times.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

川水往事 2024-09-10 19:22:21

我会存储实际的积分值并在需要时执行更新。您可以通过实施触发器来保留更改历史记录。

I would store the actual points value and perform updates when needed. You could keep a history of changes by implementing a trigger.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文