title: Normalizing an extremely big table
body: <p>I face the following issue. I have an extremely big table. This table is a heritage from the people who previously worked on the project. The table is in MS SQL Server.</p>
  
  <p>The table has the following properties:</p>
  
  <ol>
  <li>it has about 300 columns. All of them have "text" type but some of them eventually should represent other types (for example, integer or datetime). So one has to convert this text values in appropriate types before using them </li>
  <li>the table has more than 100 milliom rows. The space for the table would soon reach 1 terabyte</li>
  <li>the table does not have any indices </li>
  <li>the table does not have any implemented mechanisms of partitioning.</li>
  </ol>
  
  <p>As you may guess, it is impossible to run any reasonable query to this table. Now people only insert new records into the table but nobody uses it. So I need to restructure it. I plan to create a new structure and refill the new structure with the data from the old table. Obviously, I will implement partioning, but it is not the only thing to be done. </p>
  
  <p>One of the most important features of the table is that those fields that are purely textual (i.e. they don't have to be converted into another type) usually have frequently repeated values. So the actual variety of values in a given column is in the range of 5-30 different values. This induces the idea to make normalization: for every such a textual column I will create an additional table with the list of all the different values that may appear in this column, then I will create a (tinyint) primary key in this additional table and then will use an appropriate foreign key in the original table instead of keeping those text values in the original table. Then I will put an index on this foreign key column. The number of the columns to be processed this way is about 100.</p>
  
  <p>It raises the following questions:</p>
  
  <ol>
  <li>would this normalization really increase the speed of the queires imposing conditions on some of those 100 fields? If we forget about the size needed to keep those columns, whether would there be any increase in the performance due to the substition of the initial text-columns with tinyint-columns? If I do not do any normalization and simply put an index on those initial text columns, whether the performace will be the same as for the index on the planned tinyint-column?</li>
  <li>If I do the described normalization, then building a view showing the text values will require joining my main table with some 100 additional tables. A positive moment is that I'll do those joins for pairs "primary key"="foreign key". But still quite a big amount of tables should be joined. Here is the question: whether the performance of the queryes made to this view compare to the performance of the queries to the initial non-normalized table will be not worse? Whether the SQL Server Optimizer will really be able to optimize the query the way that allows taking the benefits of the normalization?</li>
  </ol>
  
  <p>Sorry for such a long text.</p>
  
  <p>Thanks for every comment! </p>
  
  <p>PS
  I created a related question regarding joining 100 tables;
  <a href="https://stackoverflow.com/questions/14780307/joining-100-tables">Joining 100 tables</a></p>