SQLServerCentral Article

Dimensional Modelling Case Study Part 1 - Age Group

,

Background

Age plays an important role in medicine and medical research. A patient's ages is commonly grouped into small number of age ranges, reflecting the severity of certain disease on different age groups. With COVID-19 still ravaging the world, it's important to understand the risk factors for sever COVID-19 outcomes, which increase with age.

However, different countries uses different age grouping to analyze the the severity outcomes. Based on this site: Worldometer - Coronavirus Age, Sex, Demographics, New York City Health has published their COVID-19 mortality rate base on these age groups:

  • 0-17
  • 18-44
  • 45-64
  • 65-74
  • 75+

China and many other countries present their data by 10-year increments:

  • 0-9
  • 10-19
  • 20-29
  • 30-39
  • 40-49
  • 50-59
  • 60- 69
  • 70+

Other countries may have their own versions of age groups. For instance, India adopts a slightly different version of China's by shifting one year forward, and adding two more age groups at higher end:

  • 0-10
  • 11-20
  • 21-30
  • 31-40
  • 41-50
  • 51-60
  • 61- 70
  • 71-8o
  • 81-90
  • 90+

There could be hundreds of different age groupings for COVID-19 analysis across the world from different countries and organizations. Achieving consistency in age grouping for COVID-19 data globally is a complex task but is essential for accurate analysis and effective decision-making. It requires collaboration, transparency, and ongoing efforts to refine methodologies based on emerging knowledge and best practices.

Problem

Addressing the age group challenge in dimensional modeling within a data warehouse system requires careful consideration. Typically, modeling an age group dimension involves creating a table with each row representing a specific age range. The challenge arises when varied age group requirements exist, prompting the creation of multiple dimension tables. For instance, the uneven age ranges in US COVID-19 data may necessitate more than 10 dimension tables to cover all business requirements adequately.

An alternative, though discouraged approach, is the code table approach. Here multiple age groups are placed in a single column, and another column identifies the group type. This method, criticized by Kimball in his dimensional modeling books, can lead to confusion in the model.

In Kimball's ideal star schema methodology, the golden rule suggests limiting the number of dimension entries in a fact table to 15. Exceeding this limit may result in a 'Centipede' syndrome, creating an overly complex star schema due to the need for numerous table joins. The challenge then becomes how to adhere to this rule while accommodating diverse age group dimensions.

Solution

The key lies in dimension denormalization. Similar to calendar attributes in a date dimension, age groups can be denormalized into a single age dimension due to their hierarchical relationship with time. While a date dimension may span tens of thousands of rows to support historical data, an age dimension can be more concise, covering the entire human lifespan with around 130 rows. This small, yet comprehensive, age dimension can easily incorporate various age groups, simplifying analysis with a single JOIN statement to the fact table containing age-related measures.

Just as in other dimensions, a surrogate key serves as the primary key for the age dimension table. However, unlike typical dimensions, the age dimension follows the date dimension's exception. Here, the natural key is 'age,' functioning as a smart surrogate key that can support nonexistent ages, similar to the special values used in the date dimension for nonexistent dates.

With these fundamentals established, a well-structured age dimension table can efficiently support comparative analyses of COVID-19 mortality rates across different countries. By incorporating the relevant population data and a mortality fact or aggregate table, the age dimension facilitates seamless integration of additional age groups without necessitating changes in existing fact tables, as long as they include an 'age' column based on customers' birthdates.

Now, let's structure the age dimension to accommodate all possible age groups mentioned in the first section. With this dimension in place, we can effortlessly integrate any additional age groups into our age dimension table without requiring any further changes in the relevant fact tables, as long as they include an 'age' column based on patient or customers' birthdates.

Age

AgeGroup

China

AgeGroup

India

AgeGroup

US

-1

Unknown

Unknown

Unknown

0

0-9 years

0-10 years

0-17 years

1

0-9 years

0-10 years

0-17 years

2

0-9 years

0-10 years

0-17 years

0-9 years

0-10 years

0-17 years

10

10-19 years

0-10 years

0-17 years

11

10-19 years

11-20 years

0-17 years

10-19 years

11-20 years

0-17 years

17

10-19 years

11-20  years

0-17 years

18

10-19 years

11-20 years

18-44 years

19

10-19 years

11-20 years

18-44 years

20

20-29 years

11-20 years

18-44 years

21

20-29 years

21-30 years

18-44 years

20-29 years

21-30 years

18-44 years

30

30-39 years

21-30 years

18-44 years

40

40-49 years

31-40 years

18-44 years

45

40-49 years

41-50 years

45-64 years

..

40-49 years

41-50 years

45-64 years

60

60-69 years

51-60 years

45-64 years

65

60-69 years

61-70 years

65-74 years

60-69 years

61-70 years

65-74 years

70

70-79 years

61-70 years

65-74 years

70-79 years

61-70 years

65-74 years

75

70-79 years

71-80 years

75+ years

70-79 years

71-80 years

75+ years

80

80+ years

71-80 years

75+ years

81

80+ years

81-90 years

75+ years

130

80+ years

90+ years

75+ years

In conclusion, the age dimension, enhanced by the incorporation of diverse age groups, emerges as a valuable asset, surpassing the limitations of a single age column. Absent age groups, this dimension would have been relegated to the fact table as a degenerate dimension. The versatility of this approach lies in the seamless augmentation of the age dimension with various age groups, all without the need to introduce corresponding group keys into the fact table.

This fortified age dimension offers significant advantages. Two pragmatic options for loading age groups into the dimension table include leveraging Excel for user-entered data—a seemingly laborious process that proves efficient and valuable within an hour. Alternatively, a hardcoded approach eliminates the need for integration into the ETL pipeline, resembling the creation of a date dimension where attributes are either hardcoded or calculated using date functions. Given the static nature of the age dimension vertically, occasional additions of more columns for new age groups pose no hindrance, consistently enriching the dimension.

This strategic construction of the age dimension aligns with the principles of dimensional modeling, providing a dynamic tool for comprehensive analysis. The referenced age group table, informed by authoritative sources such as the Worldometer's Covid-19 demographics report, exemplifies the adaptability of this dimension. With this robust foundation, incorporating new age groups into the dimension requires minimal effort, ensuring analytical precision and responsiveness to evolving requirements in the dynamic landscape of dimensional modeling.

Rate

5 (3)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (3)

You rated this post out of 5. Change rating