Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use flat tables or a normalized database?

I have a web application that I am currently working on that uses a MySQL database for the back-end, and I need to know what is better for my situation before I continue any further.

Simply put, in this application users will be able to construct their own forms with any number fields (they decide) and right now I have it all stored in a couple tables linked by foreign keys. A friend of mine suggests that to keep things "easy/fast" that I should convert each user's form to a flat table so that querying data from them stays fast (in case of large growth).

Should I keep the database normalized with everything pooled into relational tables with foreign keys (indexes, etc) or should I construct flat tables for every new form that a user creates?

Obviously some positives of creating flat tables is data separation (security) and query speeds would be cut down. But seriously how much gain would I get from this? I really don't want 10000 tables and to be dropping, altering, and adding all of the time, but if it will be better than I will do it... I just need some input.

Thank you

like image 616
StratusBase LLC Avatar asked Dec 01 '10 19:12

StratusBase LLC


People also ask

Why is normalized data better than Unnormalized?

Normalization increases the number of tables and joins. In contrast, denormalization reduces the number of tables and join. Disk space is wasted in denormalization because same data is stored in different places. On the contrary, disk space is optimized in a normalized table.

Is database normalization still necessary?

This is done by analyzing the information within your product tables and the links between related information. Normalization is an essential part of product information management, preventing data from being replicated in two tables at the same time or unrelated product data being gathered together in the same table.

When should you normalize database?

Normalization is a technique for organizing data in a database. It is important that a database is normalized to minimize redundancy (duplicate data) and to ensure only related data is stored in each table. It also prevents any issues stemming from database modifications such as insertions, deletions, and updates.


1 Answers

Rule of thumb. It's easier to go from normalized to denormalized than the other way around.

Start with a reasonable level of database normalization (by reasonable I mean readable, maintainable, and efficient but not prematurely optimized), then if you hit performance issues as you grow, you have the option of looking into ways in which denormalization may increase performance.

like image 156
Bob Palmer Avatar answered Oct 16 '22 15:10

Bob Palmer