1️⃣ Normalized tables → for transactions (OLTP) 2️⃣ Denormalized tables → for reporting/analytics (OLAP)
The denormalized table is usually generated from the normalized tables, not updated directly.
1️⃣ Real System Architecture
Application (Insert / Update / Delete)
│
▼
Normalized Database (OLTP)
│
│ ETL / Scheduled Job
▼
Denormalized Reporting Tables
│
▼
Dashboards / Reports
This architecture is common in systems using databases like MySQL, PostgreSQL, and Microsoft SQL Server.
2️⃣ Real Example: E-Commerce System
Imagine an online store like Amazon.
Normalized Transaction Database
Customers
| CustomerID | Name | City |
|---|---|---|
| 1 | Rahim | Dhaka |
Products
| ProductID | ProductName | Price |
|---|---|---|
| 10 | Laptop | 900 |
Orders
| OrderID | CustomerID | Date |
|---|---|---|
| 1001 | 1 | 2026-03-01 |
OrderItems
| OrderID | ProductID | Quantity |
|---|---|---|
| 1001 | 10 | 1 |
To get a report
We must join 4 tables:
SELECT c.Name, p.ProductName, o.Date, oi.Quantity
FROM Customers c
JOIN Orders o ON c.CustomerID = o.CustomerID
JOIN OrderItems oi ON o.OrderID = oi.OrderID
JOIN Products p ON oi.ProductID = p.ProductID;
For millions of orders, this becomes expensive.
3️⃣ Denormalized Reporting Table
Create a reporting table:
SalesReport
| OrderID | CustomerName | City | ProductName | Quantity | Price |
|---|---|---|---|---|---|
| 1001 | Rahim | Dhaka | Laptop | 1 | 900 |
Now a report becomes simple:
SELECT * FROM SalesReport;
No joins → very fast.
4️⃣ How the Denormalized Table Is Filled
Usually by a scheduled process:
INSERT INTO SalesReport
SELECT
o.OrderID,
c.Name,
c.City,
p.ProductName,
oi.Quantity,
p.Price
FROM Orders o
JOIN Customers c ON o.CustomerID = c.CustomerID
JOIN OrderItems oi ON o.OrderID = oi.OrderID
JOIN Products p ON oi.ProductID = p.ProductID;
This job may run:
- every hour
- every night
- via a data pipeline
Tools often used:
- Apache Spark
- Apache Airflow
- Snowflake
5️⃣ Why Companies Do This
Normalized tables are best for:
✔ inserts ✔ updates ✔ deletes ✔ data integrity
Denormalized tables are best for:
✔ dashboards ✔ analytics ✔ reporting ✔ fast queries
6️⃣ Simple Rule (Used by Engineers)
| System Type | Structure |
|---|---|
| Transaction system (OLTP) | Normalized |
| Analytics system (OLAP) | Denormalized |
7️⃣ Example You See Daily
When you open an admin dashboard showing:
Total Sales Today
Top Products
Top Customers
Revenue by City
These usually come from denormalized reporting tables.
5️⃣ OLTP vs OLAP
This concept explains why normalized vs denormalized databases exist.
OLTP (Online Transaction Processing)
Used for applications and transactions.
Examples:
- placing orders
- payments
- updating user info
Characteristics:
| Feature | OLTP |
|---|---|
| Structure | Normalized |
| Operations | Insert / Update / Delete |
| Query size | Small |
| Speed | Very fast transactions |
Examples:
- banking systems
- e-commerce orders
- ride booking apps
Common databases:
- MySQL
- PostgreSQL
- Microsoft SQL Server
OLAP (Online Analytical Processing)
Used for analytics and reporting.
Examples:
- sales reports
- dashboards
- business insights
Characteristics:
| Feature | OLAP |
|---|---|
| Structure | Denormalized |
| Operations | Mostly reads |
| Query size | Large |
| Speed | Optimized for analytics |
Common platforms:
- Snowflake
- Google BigQuery
- Amazon Redshift
6️⃣ Real Industry Architecture
Most companies combine both systems.
Application
│
▼
OLTP Database
(Normalized Tables)
│
│ ETL Pipeline
▼
Data Warehouse
(Star Schema / Denormalized)
│
▼
Analytics & Dashboards
BI tools like:
- Tableau
- Microsoft Power BI
use the OLAP layer.
✅ Quick Summary
| Concept | Purpose |
|---|---|
| Normalization | Remove redundancy |
| Denormalization | Improve reporting speed |
| Index | Speed up queries |
| OLTP | Transactions |
| OLAP | Analytics |
(Normalized vs Denormalized Database)
👉 সহজভাবে বললে:
- Normalized table → transaction (OLTP)-এর জন্য
- Denormalized table → report / analytics (OLAP)-এর জন্য
👉 আর একটা গুরুত্বপূর্ণ কথা: Denormalized table সাধারণত আলাদা করে বানানো হয় না, বরং normalized table থেকেই তৈরি করা হয়।
১️⃣ বাস্তব সিস্টেমে কিভাবে কাজ করে
একটা real application-এ data flow সাধারণত এমন হয়:
Application (Insert / Update / Delete)
│
▼
Normalized Database (OLTP)
│
│ (ETL / Scheduled Job)
▼
Denormalized Reporting Table
│
▼
Dashboard / Report
👉 মানে:
- app প্রথমে clean (normalized) database-এ data রাখে
- পরে সেখান থেকে report-এর জন্য আলাদা table বানানো হয়
২️⃣ Real Example: E-commerce (যেমন online shop)
ধরো তুমি একটা online shop বানিয়েছো।
🔹 Normalized Database (transaction-এর জন্য)
Customers (গ্রাহক)
| CustomerID | Name | City |
|---|---|---|
| 1 | Rahim | Dhaka |
Products (পণ্য)
| ProductID | ProductName | Price |
|---|---|---|
| 10 | Laptop | 900 |
Orders (অর্ডার)
| OrderID | CustomerID | Date |
|---|---|---|
| 1001 | 1 | 2026-03-01 |
OrderItems (অর্ডারের বিস্তারিত)
| OrderID | ProductID | Quantity |
|---|---|---|
| 1001 | 10 | 1 |
🔍 এখন যদি report বানাতে চাও
তাহলে ৪টা table join করতে হবে:
SELECT c.Name, p.ProductName, o.Date, oi.Quantity
FROM Customers c
JOIN Orders o ON c.CustomerID = o.CustomerID
JOIN OrderItems oi ON o.OrderID = oi.OrderID
JOIN Products p ON oi.ProductID = p.ProductID;
👉 সমস্যা:
- data বেশি হলে query slow হয়ে যায়
- performance কমে যায়
৩️⃣ Denormalized Reporting Table
এখন আমরা একটা আলাদা table বানাই:
SalesReport
| OrderID | CustomerName | City | ProductName | Quantity | Price |
|---|---|---|---|---|---|
| 1001 | Rahim | Dhaka | Laptop | 1 | 900 |
👉 এখন query:
SELECT * FROM SalesReport;
✔ কোনো join লাগছে না ✔ খুব দ্রুত result
৪️⃣ এই table কিভাবে তৈরি হয়?
সাধারণত scheduled job বা ETL process দিয়ে:
INSERT INTO SalesReport
SELECT
o.OrderID,
c.Name,
c.City,
p.ProductName,
oi.Quantity,
p.Price
FROM Orders o
JOIN Customers c ON o.CustomerID = c.CustomerID
JOIN OrderItems oi ON o.OrderID = oi.OrderID
JOIN Products p ON oi.ProductID = p.ProductID;
👉 এই কাজটা run হয়:
- প্রতি ঘন্টায়
- অথবা দিনে একবার
- অথবা automated data pipeline দিয়ে
৫️⃣ কোম্পানিগুলো এটা কেন করে?
🔹 Normalized database ভালো:
✔ insert/update/delete-এর জন্য ✔ data clean রাখতে ✔ duplicate কমাতে
🔹 Denormalized database ভালো:
✔ dashboard ✔ analytics ✔ report ✔ fast query
৬️⃣ সহজ নিয়ম (মনে রাখার মতো)
| System | Structure |
|---|---|
| OLTP (transaction) | Normalized |
| OLAP (analytics) | Denormalized |
৭️⃣ বাস্তব উদাহরণ (তুমি প্রতিদিন দেখো)
যখন তুমি admin dashboard-এ দেখো:
- Total sales today
- Top products
- Top customers
- City-wise revenue
👉 এগুলো সাধারণত denormalized table থেকে আসে
৮️⃣ OLTP vs OLAP (সহজ ব্যাখ্যা)
🔹 OLTP (Online Transaction Processing)
👉 app-এর live কাজের জন্য
উদাহরণ:
- order করা
- payment
- user info update
বৈশিষ্ট্য:
| Feature | OLTP |
|---|---|
| Structure | Normalized |
| কাজ | Insert / Update / Delete |
| Query | ছোট |
| Speed | fast transaction |
🔹 OLAP (Online Analytical Processing)
👉 report / analysis-এর জন্য
উদাহরণ:
- sales report
- dashboard
- business analysis
বৈশিষ্ট্য:
| Feature | OLAP |
|---|---|
| Structure | Denormalized |
| কাজ | mostly read |
| Query | বড় |
| Speed | analytics optimized |
৯️⃣ Real Industry Setup
বেশিরভাগ কোম্পানি দুইটাই ব্যবহার করে:
Application
│
▼
OLTP Database (Normalized)
│
▼
ETL Pipeline
│
▼
Data Warehouse (Denormalized)
│
▼
Dashboard / Analytics
✅ শেষের সারাংশ (এক লাইনে)
👉 OLTP = app চালানোর জন্য (normalized) 👉 OLAP = report দেখানোর জন্য (denormalized)
🧠 Quick Memory Trick
👉 মনে রাখো:
“App চলে normalized দিয়ে, report চলে denormalized দিয়ে”