且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在数据库中存储多项选择值

更新时间:2023-01-22 11:27:50

您现在可能没有遗漏任何东西,但是当您的需求发生变化时,您可能会后悔那个决定.您应该像您的第一直觉建议的那样将其标准化.这是正确的方法.

You might not be missing anything now, but when you're requirements change you might regret that decision. You should store it normalized like your first instinct suggested. That's the correct approach.

您所建议的是经典的过早优化.您还不知道该连接是否会成为瓶颈,因此您不知道您是否真的在购买任何性能改进.等到您可以对事物进行概要分析,然后您就会知道该部分是否需要优化.

What you're suggesting is a classic premature optimization. You don't know yet whether that join will be a bottleneck, and so you don't know whether you're actually buying any performance improvement. Wait until you can profile the thing, and then you'll know whether that piece needs to be optimized.

如果是这样,我会考虑使用物化视图,或其他一些使用规范化数据预先计算答案的方法,该方法不会被视为记录簿.

If it does, I would consider a materialized view, or some other approach that pre-computes the answer using the normalized data to a cache that is not considered the book of record.

更一般地说,如有必要,可以进行许多可能的优化,而不会以您建议的方式影响您的设计.

More generally, there are a lot of possible optimizations that could be done, if necessary, without compromising your design in the way you suggest.