Data Warehousing and Data Mining · Unit 1 · 5 hrs
Introduction to Data Warehousing
Exam-focused notes for Introduction to Data Warehousing (Data Warehousing and Data Mining, CSC420): what the TU syllabus asks and how it has actually been tested, with 15 solved past questions from this unit.
Introduction to Data Warehousing in short
This unit introduces the data warehouse as the historical, subject oriented store that feeds analytical decision making. It follows data from its creation through to its use inside a warehouse, contrasts a warehouse with the everyday operational database that runs a business, and covers the multidimensional model, the standard OLAP operations, warehouse architecture, and the schemas used to design one.
What this unit covers
- Lifecycle of data
- Types of data
- Data warehouse and data warehousing
- Differences between operational database and data warehouse
- A multidimensional data model
- OLAP operation in multidimensional data model
- Conceptual modeling of data warehouse
- Architecture of data warehouse
- Data warehouse implementation
- Data marts
- Components of data warehouse
- Need for data warehousing
- Trends in data warehousing
A multidimensional data model
2081 · 10 marks
When do we prefer trim mean for statistical description of data? Justify with an example. Describe about multi-dimensional data model and conceptual modeling of data warehouse.[10]
Show solved answerHide answer
Trim Mean for Statistical Description & Multidimensional Data Model / Conceptual Modeling of Data Warehouse
PART 1: Trim Mean - When to Prefer It and Justification
Definition of Trim Mean
The trimmed mean (trim mean) is a measure of central tendency calculated by removing a specified percentage of the smallest and largest values from a dataset before computing the arithmetic mean. If we trim p% from each end, it is called a p% trimmed mean.
Formula:
$$\bar{x}{trim} = \frac{1}{n - 2k} \sum{i=k+1}^{n-k} x_{(i)}$$
where:
- $x_{(i)}$ are the sorted (ordered) values
- $k = \lfloor p \times n / 100 \rfloor$ is the number of values trimmed from each end
- $n$ is the total number of observations
When Do We Prefer Trim Mean?
We prefer the trimmed mean over the ordinary arithmetic mean in the following situations:
-
Presence of Outliers: When the dataset contains extreme values (outliers) that distort the arithmetic mean, the trim mean provides a more robust and representative central value.
-
Skewed Distributions: When data is heavily skewed (positively or negatively), the ordinary mean is pulled toward the tail. The trim mean reduces this effect.
-
Noisy or Erroneous Data: In real-world data collection, some values may be recorded incorrectly or represent measurement errors. Trimming removes these suspicious extreme values.
-
When Median is Too Extreme: The median ignores all values except the middle one, while the arithmetic mean is too sensitive to extremes. The trim mean offers a balance between the two - it is more robust than the mean but uses more data than the median.
-
Data Mining and Statistical Description: In data preprocessing for data mining, when describing large datasets with potential noise, the trim mean gives a cleaner summary statistic.
Justification with Example
Example:
Consider the monthly salaries (in thousands) of 10 employees:
$${12, 14, 15, 16, 17, 18, 19, 20, 21, 150}$$
Step 1: Compute the Arithmetic Mean
$$\bar{x} = \frac{12 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 150}{10} = \frac{302}{10} = 30.2$$
The mean is 30.2, but 9 out of 10 employees earn between 12 and 21. The value 150 is clearly an outlier (perhaps the CEO's salary), and it has inflated the mean significantly.
Step 2: Compute the 10% Trimmed Mean
- Trim 10% from each end: $k = 0.10 \times 10 = 1$ value removed from each side
- Remove the lowest value: 12
- Remove the highest value: 150
- Remaining values: ${14, 15, 16, 17, 18, 19, 20, 21}$
$$\bar{x}_{10%} = \frac{14 + 15 + 16 + 17 + 18 + 19 + 20 + 21}{8} = \frac{140}{8} = 17.5$$
Conclusion: The trimmed mean of 17.5 is far more representative of the typical employee salary than the arithmetic mean of 30.2. This justifies using the trim mean when outliers are present.
PART 2: Multidimensional Data Model
Definition
A multidimensional data model is a data model that organizes data in multiple dimensions to facilitate complex analytical queries and reporting. It is the foundation of OLAP (Online Analytical Processing) systems and data warehouses.
- Data is viewed as a data cube with multiple dimensions.
- Each dimension represents a perspective or entity of interest (e.g., Time, Location, Product).
- The model is typically organized around a central theme (e.g., Sales), represented by a fact table.
- Facts are numerical measures such as sales amount, units sold, profit, etc.
- Each dimension may have a dimension table associated with it.
Key Components
| Component | Description |
|---|---|
| Fact Table | Central table containing numerical measures (facts) |
| Dimension Table | Tables describing the dimensions (e.g., Time, Product, Location) |
| Measures/Facts | Quantitative data: sales, revenue, units sold |
| Dimensions | Qualitative context: who, what, when, where |
OLAP Operations in Multidimensional Data Model
1. Roll-Up (Consolidation / Aggregation)
- Generates summary from lower level to higher level.
- Can be performed by:
- Reducing dimensions
- Climbing up a concept hierarchy
- Concept Hierarchy: A system of grouping things based on their order level. For example, from daily summary, weekly summary is generated; from weekly, monthly summary is generated.
- Example: Roll-up on location from cities to countries - individual city sales are aggregated into country-level totals.
2. Drill-Down
- The reverse of roll-up; navigates from summary data to more detailed data.
- Example: From yearly sales, drill down to quarterly, then monthly sales.
3. Slice
- Selects one particular dimension from a data cube, resulting in a sub-cube.
- Example: Slice on Time = "Q1 2024" to get all sales data for Q1 only.
4. Dice
- Selects two or more dimensions from a data cube to produce a sub-cube.
- Example: Dice on Location = {Nepal, India} AND Time = {Q1, Q2}.
5. Pivot (Rotate)
- Rotates the data axes to provide an alternative presentation of data.
- Example: Swapping rows and columns in a cross-tabulation.
PART 3: Conceptual Modeling of Data Warehouse
Definition
A **conceptual
2078 · 5 marks
Differentiate between star schema and snow flake schema. List any two methods for data normalization. [5]
2076 · 5 marks
How multidimensional data model helps in retrieving information? Explain with suitable example. [5]
2075 · 5 marks
How different schema are used to model data warehouse? Explain. [5]
OLAP operation in multidimensional data model
2081 · 5 marks
List any two OLAP operations with example. How do you compute rule coverage and rule accuracy? [5]
Show solved answerHide answer
OLAP Operations and Rule Coverage/Accuracy
Part 1: Two OLAP Operations with Examples
1. Roll-up (Consolidation / Aggregation)
Roll-up generates a summary from a lower level to a higher level. It can be performed by:
- Reducing dimensions, or
- Climbing up a concept hierarchy
Example: In the location dimension, data can be rolled up from city level to country level. For instance, sales data for cities like Kathmandu, Pokhara, and Biratnagar are aggregated (summed) to give total sales for Nepal as a country.
Concept hierarchy: Day → Week → Month → Year
2. Drill-down (Opposite of Roll-up)
Drill-down navigates from higher-level summarized data to lower-level detailed data. It is the reverse of roll-up, either by stepping down a concept hierarchy or by introducing additional dimensions.
Example: If we have quarterly sales data for a country, we can drill down to view monthly sales for each city within that country. This gives more granular, detailed information.
Part 2: Rule Coverage and Rule Accuracy
The quality of an association/classification rule R is measured by two factors: coverage and accuracy.
Let the rule be of the form:
R: A => B (If condition A, then class/consequence B)
Let:
- n = total number of tuples in the dataset
- nA = number of tuples satisfying condition A (antecedent)
- nA,B = number of tuples satisfying both A and B
Rule Coverage
Coverage measures how often the rule applies to the dataset. It is the fraction of tuples that satisfy the antecedent of the rule.
$$\text{Coverage}(R) = \frac{n_A}{n}$$
Example: If a dataset has 1000 tuples and 400 tuples satisfy condition A, then:
$$\text{Coverage}(R) = \frac{400}{1000} = 0.4 = 40%$$
Rule Accuracy (Confidence)
Accuracy measures how often the rule is correct. It is the fraction of tuples satisfying the antecedent that also satisfy the consequent.
$$\text{Accuracy}(R) = \frac{n_{A,B}}{n_A}$$
Example: Out of the 400 tuples satisfying condition A, suppose 300 also satisfy B, then:
$$\text{Accuracy}(R) = \frac{300}{400} = 0.75 = 75%$$
Summary Table
| Measure | Formula | Meaning |
|---|---|---|
| Coverage | $n_A / n$ | How often the rule's condition applies |
| Accuracy | $n_{A,B} / n_A$ | How often the rule is correct when it applies |
A good rule should have both high coverage (applies to many tuples) and high accuracy (is correct most of the time).
2080 · 5 marks
Explain the OLAP operations with examples. [5]
Show solved answerHide answer
OLAP Operations in Multidimensional Data Model
OLAP (Online Analytical Processing) is a technology used to perform multidimensional analysis on large volumes of data stored in a data warehouse. OLAP operations are performed on a data cube, which organizes data along multiple dimensions (e.g., time, location, product).
The key OLAP operations are described below:
1. Roll-Up (Drill-Up)
Roll-up is also known as consolidation or aggregation. It generates a summary by moving from a lower level to a higher level in a concept hierarchy, or by reducing dimensions.
Concept Hierarchy is a system of grouping things based on their order level.
Two ways to perform Roll-up:
- Reducing dimensions
- Climbing up the concept hierarchy
Example:
- In the time dimension: Daily summary → Weekly summary → Monthly summary → Yearly summary
- In the location dimension: City level data is aggregated (rolled up) to Country level data.
Rolling up on location means sales data for individual cities (e.g., Kathmandu, Pokhara) is aggregated to give total sales for Nepal (country level).
2. Drill-Down (Roll-Down)
Drill-down is the reverse of roll-up. It navigates from a higher level of summary to a lower level of detail by descending a concept hierarchy or adding new dimensions.
Example:
- Moving from yearly sales data → quarterly sales → monthly sales → daily sales.
- From country-level sales → city-level sales.
3. Slice
The slice operation selects one particular dimension from a data cube and provides a new sub-cube by fixing a single value for one dimension.
Example:
- From a 3D cube with dimensions (Time, Location, Product), fixing Time = "Q1 2024" produces a 2D slice showing sales by Location and Product for Q1 2024 only.
4. Dice
The dice operation selects two or more dimensions from a data cube and provides a sub-cube by specifying a range or list of values for multiple dimensions.
Example:
- Selecting: Location = {Kathmandu, Pokhara}, Time = {Q1, Q2}, Product = {Laptop}
- This produces a smaller sub-cube from the original data cube.
5. Pivot (Rotate)
The pivot operation rotates the data axes of the cube to provide an alternative presentation of the data. It does not change the data but changes the orientation/view of the cube.
Example:
- Swapping the Time axis with the Location axis to view data from a different angle, such as viewing sales by product across time instead of by location across time.
Summary Table
| Operation | Description | Direction |
|---|---|---|
| Roll-Up | Aggregates data; moves to higher level | Bottom to Top |
| Drill-Down | Detailed view; moves to lower level | Top to Bottom |
| Slice | Fixes one dimension; produces 2D view | Single dimension filter |
| Dice | Fixes multiple dimensions; produces sub-cube | Multi-dimension filter |
| Pivot | Rotates the data cube for alternate view | Reorientation |
These operations allow analysts and decision-makers to view data from multiple perspectives, enabling effective business intelligence and decision support.
2079 · 10 marks
Why OLAP operations are used? Discuss various OLAP operation with suitable example of each.[10]
Show solved answerHide answer
OLAP Operations in Multidimensional Data Model
Why OLAP Operations Are Used
OLAP (Online Analytical Processing) operations are used to analyze multidimensional data stored in a data warehouse. The key reasons for using OLAP operations are:
- To view and analyze data from multiple perspectives (dimensions)
- To generate summaries and aggregations at different levels of detail
- To help managers and analysts make better business decisions
- To allow interactive exploration of data by drilling into details or rolling up to summaries
- To support fast query processing on large volumes of historical data
- To enable users to slice, filter, and pivot data without writing complex SQL queries
A multidimensional data model is organized around a central theme (e.g., Sales) represented by a fact table containing numerical measures (e.g., sales amount, units sold), and dimension tables (e.g., Time, Location, Product).
OLAP Operations
1. Roll-Up (Consolidation / Aggregation)
Definition: Roll-up generates a summary by moving from a lower level to a higher level in a concept hierarchy, or by reducing dimensions.
Two ways to perform Roll-up:
- Climbing up a concept hierarchy
- Reducing the number of dimensions
Concept Hierarchy Example (Time):
Daily --> Weekly --> Monthly --> Quarterly --> Yearly
Example:
Suppose we have sales data at the city level (Kathmandu, Pokhara, Butwal). A roll-up on the Location dimension climbs from cities to countries:
| Location (City) | Sales |
|---|---|
| Kathmandu | 5000 |
| Pokhara | 3000 |
| Butwal | 2000 |
After Roll-up (City --> Country):
| Location (Country) | Sales |
|---|---|
| Nepal | 10000 |
The data is aggregated (summed) at the country level, reducing detail.
2. Drill-Down (Reverse of Roll-Up)
Definition: Drill-down is the reverse of roll-up. It navigates from a higher level summary to a lower level detail, either by stepping down a concept hierarchy or by introducing additional dimensions.
Example:
Starting from yearly sales data, a drill-down on the Time dimension moves from year to quarter:
| Year | Sales |
|---|---|
| 2023 | 40000 |
After Drill-down (Year --> Quarter):
| Quarter | Sales |
|---|---|
| Q1 | 8000 |
| Q2 | 12000 |
| Q3 | 10000 |
| Q4 | 10000 |
This gives more detailed information for analysis.
3. Slice
Definition: Slice performs a selection on one dimension of the data cube, resulting in a sub-cube. It fixes one dimension to a single value and returns the remaining dimensions.
Example:
Consider a 3D cube with dimensions: Time, Location, Product.
Slicing on Time = "Q1 2023" gives a 2D sub-cube showing sales for all locations and all products only for Q1 2023:
| Location \ Product | TV | Laptop | Phone |
|---|---|---|---|
| Kathmandu | 2000 | 3000 | 1500 |
| Pokhara | 1000 | 2000 | 800 |
One dimension (Time) is fixed; the rest are free.
4. Dice
Definition: Dice performs a selection on two or more dimensions of the data cube, resulting in a smaller sub-cube. It is like applying multiple conditions simultaneously.
Example:
From the same 3D cube (Time, Location, Product), dicing with:
- Time = "Q1 2023" OR "Q2 2023"
- Location = "Kathmandu" OR "Pokhara"
- Product = "Laptop" OR "Phone"
This produces a smaller sub-cube containing only the combinations that satisfy all three conditions, rather than a single slice.
| Time | Location | Product | Sales |
|---|---|---|---|
| Q1 | Kathmandu | Laptop | 3000 |
| Q1 | Kathmandu | Phone | 1500 |
| Q1 | Pokhara | Laptop | 2000 |
| Q2 | Kathmandu | Laptop | 3500 |
| ... | ... | ... | ... |
5. Pivot (Rotate)
Definition: Pivot (also called rotate) rotates the data axes to provide an alternative presentation of the data. It changes the orientation of the data cube to view it from a different angle without changing the data itself.
Example:
Original view (rows = Product, columns = Location):
| Product \ Location | Kathmandu | Pokhara |
|---|---|---|
| Laptop | 3000 | 2000 |
| Phone | 1500 | 800 |
After Pivot (rows = Location, columns = Product):
| Location \ Product | Laptop | Phone |
|---|---|---|
| Kathmandu | 3000 | 1500 |
| Pokhara | 2000 | 800 |
The data is the same but the perspective has changed, making it easier to analyze from a different angle.
Summary Table
| Operation | Description | Direction |
|---|---|---|
| Roll-Up | Aggregates data from lower to higher level | Bottom --> Top |
| Drill-Down | Expands data from higher to lower level | Top --> Bottom |
| Slice | Selects one value for one dimension | Fixes 1 dimension |
| Dice | Selects values for two or more dimensions | Fixes 2+ dimensions |
| Pivot | Rotates the data cube for alternate view | Changes orientation |
Data marts
2080 · 10 marks
Why the concept of data mart is important? Discuss different data warehouse schema with examples.[10]
2079 · 5 marks
Write down short notes on: a. Data Mart b. Market Basket Analysis [5]
Differences between operational database and data warehouse
2076 · 10 marks
Do pattern and information refer to same aspect? Justify. Differentiate between data warehouse and operational database.[10]
Data warehouse and data warehousing
2076 · 5 marks
Explain the four characteristics of data warehouse. [5]
Architecture of data warehouse
2076 · 5 marks
Compare the OLAP servers, ROLAP, MOLAP and HOLAP. [5]
Data warehouse implementation
2076 · 5 marks
What does data warehouse tuning mean? Describe the parameters. [5]
Components of data warehouse
2075 · 10 marks
Describe how bitmap and join indexing are used to represent OLAP data. Explain the different components of data warehouse.[10]
Make Unit 1 stick
Practice CSC420 with flashcards & quizzes