Junior — Middle
What is the purpose of denormalization in a database and what are its advantages?
sobes.tech AI
Answer from AI
Denormalization in a database is the process of intentionally adding redundant data to improve query performance. The goal is to reduce the number of table joins, which speeds up data retrieval.
Advantages of denormalization:
- Faster queries: data is stored in a form that is convenient for queries, reducing response time.
- Reduced server load: fewer join operations.
- Simplified queries: queries become simpler and more understandable.
However, denormalization increases the complexity of data maintenance, as you need to ensure data consistency during updates.
Example: instead of storing the user's address in a separate table, it can be added directly to the orders table to quickly retrieve the address when viewing an order without an additional JOIN.