Questions tagged [denormalization]

Denormalization is the process of moving from higher to lower normal forms of database modeling in order to speed up database read performance or to maintain a history.

Denormalization is a process of attempting to optimize the read performance of a database by adding redundant data, by grouping data or to maintain a history.

A fully normalized schema shows current state only. For example if in Customer table, a customer moves to other address, the old would be changed with the new one and lost. This can be solved by maintaining a copy columns in the table with an old address.

In the normalized database usually there are more tables. This means more joins needed to perform in the queries and a possible negative impact on the performance. Pre-calculated quantities can be helpful for avoiding many joins and aggregating often large sets of data.

However, denormalization always brings the danger of update anomalies to the database. It must be done deliberately and to be well documented. To make sure an application maintains denormalized data, transactions are needed. Transactions are the smallest unit of work, that must either complete entirely or not at all.

Transactions must fail, ensuring data consistency. If something doesn't work out, procedures for rebuilding the data from a scratch should take place.

Denormalizing for maintaining history is used in data warehouses. Implementing Slowly Changing Dimensions (SCD) requires extra columns in the table for older dates or and current indices.

Links

Optimizing the Database Design by Denormalizing

475 questions
405
votes
7 answers

When and why are database joins expensive?

I'm doing some research into databases and I'm looking at some limitations of relational DBs. I'm getting that joins of large tables is very expensive, but I'm not completely sure why. What does the DBMS need to do to execute a join operation,…
Rik
  • 28,507
  • 14
  • 48
  • 67
88
votes
4 answers

How does data denormalization work with the Microservice Pattern?

I just read an article on Microservices and PaaS Architecture. In that article, about a third of the way down, the author states (under Denormalize like Crazy): Refactor database schemas, and de-normalize everything, to allow complete separation…
smeeb
  • 27,777
  • 57
  • 250
  • 447
72
votes
8 answers

In what way does denormalization improve database performance?

I heard a lot about denormalization which was made to improve performance of certain application. But I've never tried to do anything related. So, I'm just curious, which places in normalized DB makes performance worse or in other words, what are…
Roman
  • 64,384
  • 92
  • 238
  • 332
52
votes
3 answers

Django: How to access original (unmodified) instance in post_save signal

I want to do a data denormalization for better performance, and put a sum of votes my blog post receives inside Post model: class Post(models.Model): """ Blog entry """ author = models.ForeignKey(User) title =…
Silver Light
  • 44,202
  • 36
  • 123
  • 164
50
votes
9 answers

When to Denormalize a Database Design

I know that normalization has been extensively discussed on Stack Overflow. I've read many of the previous discussions. I've got some additional questions though. I'm working on a legacy system with at least 100 tables. The database is has some…
Mark Evans
  • 1,343
  • 1
  • 14
  • 28
50
votes
14 answers

In terms of databases, is "Normalize for correctness, denormalize for performance" a right mantra?

Normalization leads to many essential and desirable characteristics, including aesthetic pleasure. Besides it is also theoretically "correct". In this context, denormalization is applied as a compromise, a correction to achieve performance. Is there…
Aydya
  • 1,867
  • 3
  • 20
  • 22
24
votes
0 answers

How to properly handle denormalized data synchronization in Doctrine MongoDB ODM

Denormalization of referenced data seems a pretty common practice when using MongoDB. Yet, I do not see any built-in way to handle that with Doctrine MongoDB ODM. Let's say I have a social network where users can follow each other, here are two…
23
votes
3 answers

NOSQL denormalization datamodel

Many times I read that data in NOSQL databases is stored denormalized. For instance consider a chess game record. It may not only contain the player id's that participate in the chess game, but also the first and lastname of that player. I suppose…
Stefan
  • 1,279
  • 4
  • 14
  • 28
22
votes
8 answers

What is a good way to denormalize a mysql database?

I have a large database of normalized order data that is becoming very slow to query for reporting. Many of the queries that I use in reports join five or six tables and are having to examine tens or hundreds of thousands of lines. There are lots…
Eric Goodwin
  • 2,996
  • 6
  • 25
  • 22
18
votes
2 answers

How can I add a new value to an ENUM in Postgres without locking the table?

I've tried two approaches. Approach 1: Create a new ENUM with the new value added and switch the data type in place: -- Rename existing enum ALTER TYPE animal_species RENAME TO animal_species_old; -- Create new enum with new value CREATE TYPE…
Jeff
  • 183
  • 1
  • 1
  • 5
17
votes
2 answers

How to handle changes in duplicated data in NoSQL

We're evaluating NoSQL for an upcoming project. I tend to think of things in a RDBMS way and am having trouble conceptualizing the lack of normalization. I understand that duplicating data is not considered wrong in NoSQL. What I'm having trouble…
justkevin
  • 3,089
  • 3
  • 28
  • 33
16
votes
4 answers

How to normalize / denormalize a vector to range [-1;1]

How can I normalize a vector to the range [-1;1] I would like to use function norm, because it will be faster. Also let me know how I can denormalize that vector after normalization?
neverMind
  • 1,757
  • 4
  • 29
  • 41
16
votes
3 answers

Is it better to send normalized or denormalized API response back for React+Redux applications

I'm writing a react-redux application. At the beginning it calls a single endpoint, which returns a good amount of data as a heavily nested JSON. I then normalize it and put it into my redux-orm schema. To me it seems silly to create the nested…
NateW
  • 2,856
  • 5
  • 26
  • 46
16
votes
4 answers

Denormalize nested structure in objects with Symfony 2 serializer

I'm working on a Symfony 2 project with version 2.8 and I'm using the build-in component Serializer -> http://symfony.com/doc/current/components/serializer.html I have a JSON structure provided by a web service. After deserialization, I want to…
kero_zen
  • 704
  • 1
  • 9
  • 22
15
votes
7 answers

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…
1
2 3
31 32