Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it really better to use normalized tables?

I heard my team leader say that in some past projects they had to do away with normalization to make the queries faster.

I think it may have something to do with table unions.

Is having more lean tables really less efficient than having few fat tables?

like image 657
Invisible Coder Avatar asked Feb 12 '09 05:02

Invisible Coder


1 Answers

It depends ... joining tables is inherently slower than having one big table that is 'pre-joined' ie de-normalised. However, by denormalising you're going to create data duplication and your tables are going to be larger. Normalisation is seen as a good thing, because it creates databases that can answer 'any' question, if it is properly done you can build a select to get to your data. This is not the case in some other forms of DB, and those are now (mostly) historic irrelevancies, the normalised/relation DB won that battle.

Back to your question, using de-normalisation to make things go faster is a well accepted technique. It's normally best to run your DB for a while so you know what to de-normalise and what to leave alone, and it's also common to leave the data in its 'correct' normalised form and pull data into a set of de-normalised reporting tables on a regular basis. If that process is done as part of the report run itself then the data is always up to date too.

As an example of over-normalisation I've seen DBs in the past where the days of the week, and months of the year were pulled out into separate tables - dates themselves were normalised - you can go too far.

like image 95
MrTelly Avatar answered Sep 28 '22 06:09

MrTelly