Facts and dimension tables in relation with Star and Snowflake Schema.

<b><i></i></b><b><i>FACTS AND DIMENSION TABLE</i></b>Fact tables hold numerical data, whereas dimension tables provide descriptive context to the information stored in fact tables. When tackling queries related to 'what' and 'how much,' refer to the fact table. For insights into 'who,' 'where,' 'when,' and 'why,' turn to the dimension tableA simple example is the&nbsp; e-commerce business.&nbsp;In this case, some dimensions could be Customers, Products, and Time.The Customer dimension may have attributes like CustomerID, Name, Email, and Address.The Product dimension may have ProductID, Name, Category, and Price.The Time dimension may have Date, Month, Quarter, and Year.The Fact table could be Sales, and could include:Quantity_sold (a measure)Total_sales (a measure)ProductID (a foreign key related to the Product dimension)CustomerID (a foreign key related to the Customer dimension)Date (a foreign key related to the Time dimension)Think of fact table as the ''What'' of the data (e.g. What was sold and when), think of dimension table as the ''who, what, when, where''&nbsp; (e.g. who bought the product, where it was sold).<b><i>STAR AND SNOWFLAKES SCHEMA</i></b>A star schema is a data model that stores information in multiple table types: a single fact table and multiple dimensional tables. The dimensional tables are built based on problems to be solved and they represent different aspects or perspectives of the data (e.g., time, product, location). Star schema is known for its simplicity as it is easy to understand and query because it has fewer tables.<ul><li>The snowflake schema consists of one fact table that is connected to many dimension tables, which can be connected to other dimension tables through a many-to-one relationship.&nbsp; A snowflake schema can have any number of dimensions and each dimension can have any number of levels. This schema reduces data redundancy (data redundancy is when the same piece of data exists in multiple places) but it can be more complex to query.</li></ul>

  • 0 Comments
  • 170 Views
  • Share: