问题描述
一位前同事坚持认为,一个表多但列少的数据库比表少但列多的数据库要好.例如,您将拥有姓名表、地址表、城市表等,而不是包含姓名、地址、城市、州、邮政编码等列的客户表.
他认为这种设计更高效、更灵活.也许它更灵活,但我没有资格评论它的效率.即使它更有效,我认为这些收益可能会被增加的复杂性所抵消.
那么,与具有更多列的更少表相比,更多列更少的表有什么显着的好处吗?
我在设计数据库时遵循了一些相当简单的经验法则,我认为它们可以用来帮助做出这样的决策......
一位前同事坚持认为,一个表多但列少的数据库比表少但列多的数据库要好.例如,您将拥有姓名表、地址表、城市表等,而不是包含姓名、地址、城市、州、邮政编码等列的客户表.
他认为这种设计更高效、更灵活.也许它更灵活,但我没有资格评论它的效率.即使它更有效,我认为这些收益可能会被增加的复杂性所抵消.
那么,与具有更多列的更少表相比,更多列更少的表有什么显着的好处吗?
我在设计数据库时遵循了一些相当简单的经验法则,我认为它们可以用来帮助做出这样的决策......
>
这些规则的通常结果是,最初的设计倾向于表而不是列,重点是消除冗余.随着项目的进展和非规范化点的确定,整体结构将朝着平衡发展,即以有限的冗余和列扩散来换取其他有价值的好处.
A former coworker insisted that a database with more tables with fewer columns each is better than one with fewer tables with more columns each. For example rather than a customer table with name, address, city, state, zip, etc. columns, you would have a name table, an address table, a city table, etc.
He argued this design was more efficient and flexible. Perhaps it is more flexible, but I am not qualified to comment on its efficiency. Even if it is more efficient, I think those gains may be outweighed by the added complexity.
So, are there any significant benefits to more tables with fewer columns over fewer tables with more columns?
I have a few fairly simple rules of thumb I follow when designing databases, which I think can be used to help make decisions like this....
The usual result of these rules is that the initial design will favor tables over columns, with a focus on eliminating redundancy. As the project progresses and denormalization points are identified, the overall structure will evolve toward a balance that compromises with limited redundancy and column proliferation in exchange for other valuable benefits.
这篇关于什么是更好的数据库设计:更多的表还是更多的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!