Data Warehousing and Data MiningUnit 118 min read
Data Warehousing & Mining: Definitions, Systems, and Applications
Unit 1 of Data Warehousing and Data Mining introduces core concepts like data warehouses, OLAP, ETL, and data mining tasks (classification, clustering, association rules), explains their architecture (star schema, snowflake), and contrasts OLTP vs. OLAP systems—essential for understanding how raw data transforms into a
1. Core Definitions: What Are Data Warehousing and Data Mining?
Data Warehousing
A data warehouse (DW) is a subject-oriented, integrated, time-variant, and non-volatile collection of data designed to support decision-making in organizations. It consolidates data from multiple operational databases (OLTP systems) into a unified repository for analytical processing (OLAP).
Data Mining
Data mining is the process of discovering hidden patterns, correlations, and trends in large datasets using statistical, machine learning, and database techniques. It answers questions like:
- "Which products are frequently bought together?" (Association rules)
- "Can we predict customer churn?" (Classification)
- "How can we group similar customers?" (Clustering)
2. Key Components of a Data Warehouse
A typical DW system consists of:
| Component | Description | Example in Nepal |
|---|---|---|
| Data Sources | OLTP databases, flat files, APIs, or external feeds (e.g., NEPSE stock data). | Ncell’s customer transaction logs, Daraz’s order history. |
| ETL (Extract, Transform, Load) | Cleans, transforms, and loads raw data into the DW. | Khalti’s ETL pipeline to aggregate merchant transactions for fraud detection. |
| Data Warehouse DB | Stores structured data in star/snowflake schemas (fact tables + dimensions). | NTC’s DW for analyzing network traffic patterns across Nepal. |
| OLAP Server | Supports multidimensional analysis (slicing, dicing, drilling). | eSewa’s OLAP cube for visualizing citizen service usage trends. |
| Front-End Tools | BI tools (Tableau, Power BI) or custom dashboards. | Pathao’s dashboard for ride-demand forecasting. |
| Metadata Repository | Stores definitions of data (e.g., tables, columns, transformations). | NEPSE’s metadata for stock market historical data. |
3. OLTP vs. OLAP: The Core Difference
flowchart LR
A["OLTP (Operational Systems)"] -->|"Focus"| B["Transactions\n(CRUD operations)"]
A -->|"Users"| C["End-users\n(Clerks, Customers)"]
A -->|"Data"| D["Normalized\n(3NF, BCNF)"]
A -->|"Response Time"| E["Fast\n(<2 sec)"]
A -->|"Example"| F["Bank ATM\n(Khalti transactions)"]
G["OLAP (Analytical Systems)"] -->|"Focus"| H["Analytics\n(Aggregations, Trends)"]
G -->|"Users"| I["Analysts\n(Managers, Data Scientists)"]
G -->|"Data"| J["Denormalized\n(Data Warehouse)"]
G -->|"Response Time"| K["Slow\n(Minutes to hours)"]
G -->|"Example"| L["NTC Traffic Analysis\n(eSewa service trends)"]Why OLAP Needs a Data Warehouse?
- OLTP systems (e.g., bank databases) are optimized for transactions, not analysis.
- OLAP requires:
- Aggregated data (pre-computed summaries).
- Historical data (time-series trends).
- Multidimensional views (e.g., "Sales by region, product, and quarter").
Example:
- OLTP: A customer buys a phone on Daraz (single transaction).
- OLAP: Analyzing "Which regions buy iPhones vs. Xiaomi in Q3 2023?"
4. Data Warehouse Schemas: Star vs. Snowflake
Star Schema
- Simplest design: 1 fact table (numeric measures) + dimension tables (descriptive attributes).
- Pros: Fast queries, easy to understand.
- Cons: Redundancy in dimension tables.
Snowflake Schema
- Normalized dimensions: Dimension tables are further broken down (e.g.,
Datesplits intoYear,Month,Day). - Pros: Reduces redundancy.
- Cons: Slower queries due to joins.
Real-World Example:
- Star Schema: eSewa’s dashboard showing "Total transactions by district, month, and service type."
- Snowflake Schema: NTC’s DW breaking down
DateintoYear,Quarter,Weekdayfor granular traffic analysis.
5. ETL Process: How Raw Data Becomes Usable
ETL stands for Extract, Transform, Load—the pipeline that moves data into a DW.
flowchart LR
A["Extract"] -->|"From"| B["OLTP DBs\nAPIs\nFlat Files"]
B --> C["Transform"]
C -->|"Steps"| D["Cleaning\nNormalization\nAggregation\nDiscretization"]
C --> E["Load"]
E --> F["Data Warehouse\n(Star/Snowflake)"]
F --> G["OLAP Engine\n(BI Tools)"]Key ETL Tasks
| Task | Description | Example in Nepal |
|---|---|---|
| Data Cleaning | Handles missing values, duplicates, and outliers. | Khalti removing duplicate transactions from merchant logs. |
| Data Integration | Merges data from multiple sources (e.g., Ncell + NTC for customer behavior). | Daraz combining order data with payment data from Khalti. |
| Data Transformation | Converts data into a consistent format (e.g., standardizing dates). | NEPSE converting stock prices from multiple exchanges into a single DW. |
| Aggregation | Pre-computes summaries (e.g., daily sales → monthly sales). | Pathao aggregating ride data into hourly demand heatmaps. |
| Discretization | Converts continuous data into bins (e.g., age groups: 18-25, 26-35). | NTC classifying traffic speed into "Low," "Medium," "High" for analysis. |
6. OLAP Operations: Slicing, Dicing, Drilling
OLAP enables multidimensional analysis using:
| Operation | Definition | Example |
|---|---|---|
| Slice | Selecting a single dimension’s value (e.g., "Sales in Kathmandu"). | Filtering Daraz orders where Region = Kathmandu. |
| Dice | Selecting a subset along multiple dimensions (e.g., "Sales in Kathmandu for iPhones in Q3"). | Query: WHERE Region = 'Kathmandu' AND Product = 'iPhone' AND Quarter = 'Q3'. |
| Roll-Up | Aggregating data (e.g., daily → monthly sales). | Summing Pathao’s daily rides into monthly revenue. |
| Drill-Down | Zooming into details (e.g., monthly → weekly sales). | Starting with "Total sales in Nepal" → drilling down to "Sales in Pokhara by week." |
| Pivot | Rotating dimensions (e.g., rows → columns). | Swapping "Product" and "Region" axes in a sales report. |
| Drill-Across | Comparing data across dimensions (e.g., "Compare sales of Product A vs. Product B"). | Comparing iPhone vs. Xiaomi sales in the same report. |
7. Data Mining Tasks: What Can We Discover?
Data mining tasks are categorized into descriptive (summarizing data) and predictive (making predictions).
Descriptive Tasks
| Task | Purpose | Example in Nepal |
|---|---|---|
| Summarization | Generates simple summaries (e.g., "Top 10 products sold on Daraz"). | NEPSE’s summary: "Top 5 stocks with highest volatility in 2023." |
| Characterization | Describes general features of a group (e.g., "Customers who buy iPhones"). | Khalti’s report: "Khalti users in Kathmandu spend 30% more on digital payments." |
| Discrimination | Highlights differences between groups (e.g., "Why do Pathao users in Pokhara tip more?"). | NTC’s analysis: "Traffic congestion is 40% higher in Lalitpur than in Bhaktapur." |
| Association Rules | Finds co-occurring items (e.g., "Customers who buy X also buy Y"). | Daraz’s rule: {Laptop} → {Mouse} with 60% confidence. |
| Clustering | Groups similar data points (e.g., customer segmentation). | Ncell’s clustering: "Group customers by usage patterns (High, Medium, Low)." |
| Outlier Detection | Identifies anomalies (e.g., fraudulent transactions). | Khalti flagging a transaction of ₹50,000 in a small shop. |
Predictive Tasks
| Task | Purpose | Example in Nepal |
|---|---|---|
| Classification | Predicts a category (e.g., "Will this customer churn?"). | Ncell’s model: "Predict if a customer will switch to NTC." |
| Regression | Predicts a continuous value (e.g., "What will be the stock price tomorrow?"). | NEPSE’s model: "Forecast NABIL’s closing price." |
| Time-Series Analysis | Predicts future trends (e.g., "Will traffic increase on Dashain?"). | NTC’s model: "Predict peak hours during Dashain for route optimization." |
8. Data Mining Process: From Data to Insights
flowchart TD
A["Business Understanding"] --> B["Data Understanding"]
B --> C["Data Preparation"]
C --> D["Modeling"]
D --> E["Evaluation"]
E --> F["Deployment"]
F --> G["Feedback Loop"]Step-by-Step Workflow
- Business Understanding
- Define the goal (e.g., "Reduce customer churn for Ncell").
- Data Understanding
- Explore data sources (e.g., Ncell’s call logs, billing data).
- Data Preparation (ETL)
- Clean, transform, and load data into a DW.
- Modeling
- Apply algorithms (e.g., decision trees for classification).
- Evaluation
- Test model accuracy (e.g., 85% precision in churn prediction).
- Deployment
- Integrate into business processes (e.g., Ncell’s CRM system).
- Feedback Loop
- Monitor and retrain the model (e.g., quarterly updates).
9. Real-World Applications in Nepal
Example 1: Khalti’s Fraud Detection (Association Rules + Clustering)
- Problem: Khalti needs to detect unusual transaction patterns (e.g., a merchant suddenly processing 10x more transactions).
- Solution:
- Association Rules: Mine rules like
{Merchant_X, High_Amount} → {Fraud}. - Clustering: Group merchants by transaction behavior; flag outliers.
- Association Rules: Mine rules like
- Outcome: Reduced fraudulent transactions by 30%.
Example 2: Daraz’s Recommendation Engine (Collaborative Filtering)
- Problem: Daraz wants to recommend products to users.
- Solution:
- Clustering: Group users by purchase history (e.g., "Tech Enthusiasts," "Fashion Lovers").
- Association Rules: Find frequent itemsets (e.g.,
{Laptop} → {Mouse}).
- Outcome: 20% increase in cross-selling revenue.
Example 3: NTC’s Traffic Prediction (Time-Series + Classification)
- Problem: NTC wants to predict traffic congestion to optimize routes.
- Solution:
- Time-Series Analysis: Forecast traffic volume using historical data.
- Classification: Predict "High," "Medium," or "Low" congestion zones.
- Outcome: Reduced travel time by 15% during peak hours.
10. Worked Example: K-Means Clustering (From Past Exam)
Problem:
Apply K(=2)-Means algorithm to the dataset:
(185, 72), (170, 56), (168, 60), (179, 68), (182, 72), (188, 77)
Initial Centroids: First two points (185, 72) and (170, 56).
Iteration 1
Assign Points to Nearest Centroid:
- Distance formula: .
- Calculate distances for each point to both centroids.
Point Distance to (185,72) Distance to (170,56) Cluster (185,72) 0 18.4 1 (170,56) 18.4 0 2 (168,60) 18.0 5.4 2 (179,68) 11.4 13.4 1 (182,72) 7.1 15.5 1 (188,77) 6.4 20.6 1 Update Centroids:
- Cluster 1: Mean of
(185,72), (179,68), (182,72), (188,77). - Cluster 2: Mean of
(170,56), (168,60).
- Cluster 1: Mean of
Iteration 2
Reassign Points:
- Recalculate distances to new centroids
(183.5, 71.75)and(169, 58).
Point Distance to (183.5,71.75) Distance to (169,58) Cluster (185,72) 1.5 18.0 1 (170,56) 15.5 2.0 2 (168,60) 16.0 2.2 2 (179,68) 2.8 13.0 1 (182,72) 1.5 15.5 1 (188,77) 4.5 20.6 1 - Recalculate distances to new centroids
Final Clusters:
- Cluster 1:
(185,72), (179,68), (182,72), (188,77) - Cluster 2:
(170,56), (168,60)
- Cluster 1:
Visualization:
graph TD
A["Centroid 1\n(183.5, 71.75)"] --> B["(185,72)"]
A --> C["(179,68)"]
A --> D["(182,72)"]
A --> E["(188,77)"]
F["Centroid 2\n(169, 58)"] --> G["(170,56)"]
F --> H["(168,60)"]11. Exam Tip: How to Score Full Marks
Definitions:
- Always define terms precisely with examples.
- Example: "A data warehouse is a subject-oriented, integrated, time-variant, and non-volatile repository..."
Diagrams:
- Draw star/snowflake schemas for DW questions.
- Use distance formulas for clustering (K-Means) and show iterations.
OLAP vs. OLTP:
- Compare purpose, users, data structure, and response time in a table.
ETL Steps:
- List Extract, Transform, Load with real-world examples (e.g., Khalti’s ETL).
Data Mining Tasks:
- Classify tasks into descriptive (summarization, association) and predictive (classification, regression).
Worked Examples:
- For K-Means, show:
- Distance calculations.
- Centroid updates.
- Final clusters.
- For association rules, use the support-confidence-lift framework.
- For K-Means, show:
Common Pitfalls:
- Avoid: Vague answers like "OLAP is for analysis." Instead, say "OLAP enables multidimensional analysis via slicing, dicing, and drilling on aggregated data stored in a star/snowflake schema."
- Do: Use Nepali examples (e.g., Ncell, Daraz, Khalti) to illustrate concepts.
12. Quick Revision Table
| Concept | Key Points | Example |
|---|---|---|
| Data Warehouse | Subject-oriented, integrated, time-variant, non-volatile. | NTC’s DW for traffic analysis. |
| OLAP | Multidimensional analysis (slice, dice, drill). | eSewa’s dashboard for citizen service trends. |
| ETL | Extract, Transform, Load. | Khalti’s pipeline to clean merchant transaction data. |
| Star Schema | 1 fact table + dimensions. | Daraz’s sales fact table linked to Product, Customer, Date. |
| Snowflake Schema | Normalized dimensions (e.g., Date → Year, Month). |
NEPSE’s DW breaking down Date into hierarchical dimensions. |
| K-Means | Partitional clustering with centroids. | Ncell clustering customers by usage patterns. |
| Association Rules | {X} → {Y} with support, confidence, lift. |
Daraz’s rule: {Laptop} → {Mouse} with 60% confidence. |
| Classification | Predicts categories (e.g., churn, spam). | Ncell’s model to predict customer churn. |
| Clustering | Groups similar data (unsupervised). | NTC grouping traffic routes by congestion levels. |
Based on the TU BSc CSIT syllabus for Data Warehousing and Data Mining (CSC410), unit 1.
Discussion
Loading…