[英]Should I separate redundant data in my database?
I have a database app that stores prices for things in different places. 我有一个数据库应用程序,用于存储不同位置的商品价格。 Each price has the following data associated with it:
每个价格都有以下相关数据:
The last three items (pID, country, pricetype) can be thought of as one composite item describing the purpose of the price; 可以将最后三个项目(pID,国家/地区,价格类型)视为描述价格目的的一个综合项目。 there is a lot of redundancy in this data.
此数据中有很多冗余。 So I'm thinking: separate those out into their own table to save space and simplify queries.
所以我在想:将它们分成各自的表以节省空间并简化查询。
Normal:
Prices (price_id, price, date, product_id, country_id, pricetype_id)
vs:
Prices (price_id, price, date, descriptor_id)
Descriptors (descriptor_id, product_id, country_id, pricetype_id)
Is this worth the added programming effort required? 这值得进行额外的编程工作吗? Will it be more or less extensible/maintainable in the long run?
从长远来看,它会或多或少地具有可扩展性/可维护性吗?
Is this worth the added programming effort required?
这值得进行额外的编程工作吗?
Yes 是
Will it be more or less extensible/maintainable in the long run?
从长远来看,它会或多或少地具有可扩展性/可维护性吗?
More extensible and easier to maintain. 更可扩展,更易于维护。
In general 一般来说
You should always normalize to at least 3NF. 您应该始终将其标准化为至少3NF。
See this article: http://databases.about.com/od/specificproducts/a/normalization.htm 看到这篇文章: http : //databases.about.com/od/specificproducts/a/normalization.htm
It depends on the amount of data you are expecting in that table. 这取决于您在该表中期望的数据量。 If you have no performance/storage problems, you don't need separate tables (for performance reasons).
如果您没有性能/存储问题,则不需要单独的表(出于性能原因)。
On the other hand, you will get all disadvantages that come with redundancy. 另一方面,您将获得冗余带来的所有缺点。 You have to check your data for inconsistencies etc.
您必须检查数据是否存在不一致等情况。
But: Regardless of the design you choose, there's still time to change the road you're on. 但是:无论您选择哪种设计,仍然有时间改变您的发展道路。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.