How do you determine how far to normalize a database?

前端 未结 13 2067
醉梦人生
醉梦人生 2020-11-29 06:36

When creating a database structure, what are good guidelines to follow or good ways to determine how far a database should be normalized? Should you create an un-normalized

相关标签:
13条回答
  • 2020-11-29 07:24

    @GrizzlyGuru A wise man once told me "normalize till it hurts, denormalize till it works".

    It hasn't failed me yet :)

    I disagree about starting with it in un-normalized form however, in my experience its' been easier to adapt your application to deal with a less normalized database than a more-normalized one. It could also lead to situations where its' working "well enough" so you never get around to normalizing it (until its' too late!)

    0 讨论(0)
  • 2020-11-29 07:24

    Often if you normalize as far as your other software will let you, you'll be done.

    For example, when using Object-Relational mapping technology, you'll have a rich set of semantics for various many-to-one and many-to-many relationships. Under the hood that'll provide join tables with effectively 2 primary keys. While relatively rare, true normalization often gives you relations with 3 or more primary keys. In cases like this, I prefer to stick with the O/R and roll my own code to avoid the various DB anomalies.

    0 讨论(0)
  • 2020-11-29 07:27

    The original poster never described in what situation the database will be used. If it's going to be any type of data warehousing project where at some point you will need cubes (OLAP) processing data for some front-end, it would be wiser to start off with star schema (fact tables + dimension) rather than looking into normalization. The Kimball books will be of great help in this case.

    0 讨论(0)
  • 2020-11-29 07:28

    I believe starting with an un-normalized database and moving toward normalized as you progress is usually easiest to get started. To the question of how far to normalize, my philosophy is to normalize until is starts to hurt. That may sound a little flippant, but it generally is a good way to gauge how far to take it.

    0 讨论(0)
  • 2020-11-29 07:28

    Having a normalized database will give you the most flexibility and the easiest maintenance. I always start with a normalized database and then un-normalize only when there is an real life problem that needs addressing.

    I view this similarly to code performance i.e. write maintainable, flexible code and make compromises for performance when you know that there is a performance problem.

    0 讨论(0)
  • 2020-11-29 07:33

    I agree that it is typically better to start out with a normalized DB and then denormalize to solve very specific problems, but I'd probably start at Boyce-Codd Normal Form instead of 3rd Normal Form.

    0 讨论(0)
提交回复
热议问题