Normalization might look like a pain in the a** right now - but trust me, in the long run, you'll be glad you did it! Non-normalized "flat" tables with everything but the kitchen sink in them will become very unmanageable over time, data inconsistencies will creep in, and before you know it, you have a huge steaming pile of crap - errrg - data that doesn't make any sense anymore!
Yes, joining tables can be a bit of work - but especially for displaying data, you should definitely check out views which can help you write those JOINs once and then just use them as "virtual tables" that hold everything again.
Database normalization - up to roughly 3NF - is a good thing (TM) for sure! I would always recommend doing it, and then maybe at that point introduce back some limited de-normalization where performance needs might require it - but only in a very controlled way, and with your full understanding and knowledge that you are in fact denormalizing something again.
It depends on what you typically query, how you typically query, how often you query, how large the table is to hold all the data.... etc. It depends. An example of when you might not want to normalize would be if you need to query aggregated or derived data regularly and the process of compiling it takes a "long time." Usually though I think data should be normalized.
That being said, I'm not sure what you described is "Normalization" as much as it's separation. Normalization would involve removing duplicated data in different columns.
Let's take your example of packaging... It seems to me like you've made a record in some ProductBasePackaging which is related by PartNumber to the ProductBase or something.
In reality, if you were normalizing the data... you'd have a ProductBasePackaging row only for each type of packaging... like maybe you ship 1000 different products but only use 10 different types of boxes. ProductBasePackaging would have 10 rows, each having info on a unique box... then ProductBase would reference its required box by PackagingID
发布评论
评论(2)
标准化现在可能看起来很痛苦 - 但相信我,从长远来看,你会很高兴你做到了!随着时间的推移,除了厨房水槽之外的所有东西都包含在非标准化的“平面”桌子上,随着时间的推移,数据不一致的情况会逐渐出现,在你意识到之前,你就会有一大堆热气腾腾的垃圾——呃——数据不管理。不再有任何意义了!
是的,连接表可能需要一些工作 - 但特别是对于显示数据,您绝对应该查看视图,它可以帮助您编写一次这些连接,然后将它们用作保存数据的“虚拟表”一切又来了。
数据库规范化 - 高达大约 3NF - 肯定是一件好事(TM)!我总是建议这样做,然后也许在那时引入一些有限的反规范化,其中性能需求可能需要它 - 但只能以一种非常受控的方式,并且在您充分理解和了解您实际上再次对某些东西进行非规范化的情况下。
Normalization might look like a pain in the a** right now - but trust me, in the long run, you'll be glad you did it! Non-normalized "flat" tables with everything but the kitchen sink in them will become very unmanageable over time, data inconsistencies will creep in, and before you know it, you have a huge steaming pile of crap - errrg - data that doesn't make any sense anymore!
Yes, joining tables can be a bit of work - but especially for displaying data, you should definitely check out views which can help you write those JOINs once and then just use them as "virtual tables" that hold everything again.
Database normalization - up to roughly 3NF - is a good thing (TM) for sure! I would always recommend doing it, and then maybe at that point introduce back some limited de-normalization where performance needs might require it - but only in a very controlled way, and with your full understanding and knowledge that you are in fact denormalizing something again.
答案是这取决于。
这取决于您通常查询的内容、通常查询的方式、查询的频率、容纳所有数据的表有多大......等等。这取决于。
您可能不想想要标准化的一个例子是,如果您需要定期查询聚合或派生数据,并且编译过程需要“很长时间”。
通常,但我认为数据应该标准化。
话虽这么说,我不确定你所描述的是“标准化”还是分离。标准化涉及删除不同列中的重复数据。
让我们以您的包装为例...在我看来,您已经在一些
ProductBasePackaging
中做了记录,该记录通过PartNumber
与ProductBase
相关联代码>或其他东西。实际上,如果您对数据进行标准化...您将仅针对每种类型的包装有一个
ProductBasePackaging
行...就像您可能运送 1000 种不同的产品,但只使用 10 种不同类型的盒子。ProductBasePackaging
将有 10 行,每行都有一个唯一盒子的信息...然后ProductBase
将通过PackagingID
引用其所需的盒子The answer is it depends.
It depends on what you typically query, how you typically query, how often you query, how large the table is to hold all the data.... etc. It depends.
An example of when you might not want to normalize would be if you need to query aggregated or derived data regularly and the process of compiling it takes a "long time."
Usually though I think data should be normalized.
That being said, I'm not sure what you described is "Normalization" as much as it's separation. Normalization would involve removing duplicated data in different columns.
Let's take your example of packaging... It seems to me like you've made a record in some
ProductBasePackaging
which is related byPartNumber
to theProductBase
or something.In reality, if you were normalizing the data... you'd have a
ProductBasePackaging
row only for each type of packaging... like maybe you ship 1000 different products but only use 10 different types of boxes.ProductBasePackaging
would have 10 rows, each having info on a unique box... thenProductBase
would reference its required box byPackagingID