<p>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 database and split it apart as the project progresses? Should you create it fully normalized and combine tables as needed for performance?</p>

[{'answer_id': 47720, 'author': 'GrizzlyGuru', 'author_id': 4854, 'author_profile': 'https://Stackoverflow.com/users/4854', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 47722, 'author': 'Jason Baker', 'author_id': 2147, 'author_profile': 'https://Stackoverflow.com/users/2147', 'pm_score': 2, 'selected': False, 'text': '<p>Jeff has a pretty good overview of his philosophy on his blog:  <a href="http://www.codinghorror.com/blog/archives/001152.html" rel="nofollow noreferrer">Maybe normalization isn\'t normal</a>.  The main thing is: don\'t overdo normalization.  But I think an even bigger point to take away is that it probably doesn\'t matter too much.  Unless you\'re running the next Google, you probably won\'t notice much of a difference until your application grows.</p>\n'}, {'answer_id': 47726, 'author': 'David Basarab', 'author_id': 2469, 'author_profile': 'https://Stackoverflow.com/users/2469', 'pm_score': 2, 'selected': False, 'text': "<p>Database normizational I feel is an art form.</p>\n\n<p>You don't want to over normalize your database because you will have too many tables and it will cause your queries of even simple objects take longer than they should.</p>\n\n<p>A good rule of thumb I follow is to normalize the same information repeated over and over again.  </p>\n\n<p>For example if you are creating a contact management application it would make sense to have Address (Street, City, State, Zip, etc. . ) as its own table.</p>\n\n<p>However if you have only 2 types of contacts, Business or personal, do you need a contact type table if you know you are only going to have 2?  For me no.</p>\n\n<p>I would start by first figuring out the datatypes you need.  Use a modeling program to help like Visio.  You don't want to start with a non-normalized database because you will eventually normalize.  Start by putting objects in there logical groupings, as you see data repeated take that data into a new table.  I would keep up with that process until you feel you have the database designed.  </p>\n\n<p>Let testing tell you if you need to combine tables.  A well written query can cover any over normalization.</p>\n"}, {'answer_id': 47731, 'author': 'sergeb', 'author_id': 4808, 'author_profile': 'https://Stackoverflow.com/users/4808', 'pm_score': 5, 'selected': True, 'text': '<p>You want to start designing a normalized database up to 3rd normal form. As you develop the business logic layer you may decide you have to denormalize a bit but <em>never, never</em> go below the 3rd form. Always, keep 1st and 2nd form compliant. You want to denormalize for simplicity of code, not for performance. Use indexes and stored procedures for that :)</p>\n\n<p>The reason not "normalize as you go" is that you would have to modify the code you already have written most every time you modify the database design.</p>\n\n<p>There are a couple of good articles:</p>\n\n<p><a href="http://www.agiledata.org/essays/dataNormalization.html" rel="nofollow noreferrer">http://www.agiledata.org/essays/dataNormalization.html</a></p>\n'}, {'answer_id': 47741, 'author': 'AlexCuse', 'author_id': 794, 'author_profile': 'https://Stackoverflow.com/users/794', 'pm_score': 4, 'selected': False, 'text': '<p>@GrizzlyGuru A wise man once told me "normalize till it hurts, denormalize till it works". </p>\n\n<p>It hasn\'t failed me yet :)</p>\n\n<p>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!)</p>\n'}, {'answer_id': 47748, 'author': 'Purfideas', 'author_id': 4615, 'author_profile': 'https://Stackoverflow.com/users/4615', 'pm_score': -1, 'selected': False, 'text': "<p>Often if you normalize as far as your other software will let you, you'll be done.</p>\n\n<p>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.</p>\n"}, {'answer_id': 48256, 'author': 'jase', 'author_id': 4216, 'author_profile': 'https://Stackoverflow.com/users/4216', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n\n<p>I view this similarly to code performance i.e. write maintainable, flexible code and make compromises for performance when you <em>know</em> that there is a performance problem. </p>\n'}, {'answer_id': 48459, 'author': 'Hank Gay', 'author_id': 4203, 'author_profile': 'https://Stackoverflow.com/users/4203', 'pm_score': 1, 'selected': False, 'text': '<p>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 <a href="http://en.wikipedia.org/wiki/Boyce-Codd_Normal_Form" rel="nofollow noreferrer">Boyce-Codd Normal Form</a> instead of 3rd Normal Form.</p>\n'}, {'answer_id': 82866, 'author': 'JacquesB', 'author_id': 7488, 'author_profile': 'https://Stackoverflow.com/users/7488', 'pm_score': 3, 'selected': False, 'text': '<p>Normalization means eliminating redundant data. In other words, an un-normalized or de-normalized database is a database where the same information will be repeated in multiple different places. This means you have to write more complex update statement to ensure you update the same data everywhere, otherwise you get inconsistent data which in turn means the output of queries is unrealiable. </p>\n\n<p>This is a pretty huge problem, so I would say denormalization hurts, not the other way around.</p>\n\n<p>In some case you may deliberately decide to denormalize specific parts of a database, if you judge that the benefit outweighs the extra work in updating data and the risk of data corruption. For example with datawarehouses, where data is aggregated for performance reasons, and data if often not updated after the initial entry which reduce the risk of inconsistencies.</p>\n\n<p>But in general be weary of denormalizing for performance. For example the performance benefit of a denormalized join can typically be achieved by using <em>materialized view</em> (also called <em>indexed view</em>), which will be as fast as querying a denormalized table, but still protects the consistency of the data.</p>\n'}, {'answer_id': 82919, 'author': 'Adam Vigh', 'author_id': 1613872, 'author_profile': 'https://Stackoverflow.com/users/1613872', 'pm_score': -1, 'selected': False, 'text': "<p>Just try to use common sense.</p>\n\n<p>Also some say - and I have to agree with them - that, if you're finding yourself joining 6 (the magic number) tables together in most of your queries - not including reporting related ones- , than you might consider denormalizing a bit.</p>\n"}, {'answer_id': 83196, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>The truth is that "it depends."  It depends on a lot of factors including:</p>\n\n<ul>\n<li>Code (Hand-coded or Tool driven (like ETL packages))\n<li>Primary Application (Transaction Processing, Data Warehousing, Reporting)\n<li>Type of Database (MySQL, DB/2, Oracle, Netezza, etc.)\n<li>Database Architecture (Tablular, Columnar)\n<li>DBA Quality (proactive, reactive, inactive)\n<li>Expected Data Quality (do you want to enforce data quality at the application level or the database level?)\n</ul>\n'}, {'answer_id': 91414, 'author': 'Simon Collins', 'author_id': 12412, 'author_profile': 'https://Stackoverflow.com/users/12412', 'pm_score': 1, 'selected': False, 'text': '<p>I agree that you should normalise as much as possible and only denormalise if absolutely necessary for performance. And with materialised views or caching schemes this is often not necessary.</p>\n\n<p>The thing to bare in mind is that by normalising your model you are giving the database more information on how to constrain your data so that you can remove the risk of update anomalies that can occur in incompletely normalised models.</p>\n\n<p>If you denormalise then you either need to live with the fact that you may get update anomolies or you need to implement the constraint validation yourself in your application code. This takes away a lot of the benefit of using a DBMS which lets you define these constraints declaratively.</p>\n\n<p>So assuming the same quality of code, denormalising may not actually give you better performance.</p>\n\n<p>Another thing to mention is that hardware is cheap these days so throwing extra processing power at the problem is often more cost effective than accepting the potential costs of cleaning up corrupted data.</p>\n'}, {'answer_id': 280323, 'author': 'Jedidja', 'author_id': 9913, 'author_profile': 'https://Stackoverflow.com/users/9913', 'pm_score': 2, 'selected': False, 'text': "<p>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.</p>\n"}]
['https://Stackoverflow.com/questions/47711', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4924/']