SCHEMA

<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>What is a Star Schema?</b></p> <p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal">A star schema is a way to organize a database that makes it easier to analyze data. It consists of:</p> <ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l3 level1 lfo1;tab-stops:list .5in"><b>Central Table (Fact Table):</b> Imagine you have one big table in the middle that holds the main data you want to analyze, like sales transactions. This table is called the "fact table."</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l3 level1 lfo1;tab-stops:list .5in"><b>Surrounding Tables (Dimension Tables):</b> Around this big table, you have smaller tables that provide more details about the data, like products, dates, and stores. These are called "dimension tables."</li> </ul> <p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>How it Looks</b></p> <ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l0 level1 lfo2;tab-stops:list .5in">The central fact table connects to each dimension table directly, forming a shape that looks like a star, hence the name "star schema."</li> </ul> <p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>Example</b></p> <ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l1 level1 lfo3;tab-stops:list .5in"><b>Fact Table (Sales):</b> Contains information about each sale, like the amount sold, quantity, and sale date.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l1 level1 lfo3;tab-stops:list .5in"><b>Dimension Tables:</b></li> <ul type="circle"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l1 level2 lfo3;tab-stops:list 1.0in"><b>Product Table:&nbsp;</b>Details about each product, like name and category.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l1 level2 lfo3;tab-stops:list 1.0in"><b>Date Table:&nbsp;</b>Information about dates, like year, month, and day.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l1 level2 lfo3;tab-stops:list 1.0in"><b>Store Table:&nbsp;</b>Details about each store, like location and size.</li> </ul> </ul> <p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>Why Use a Star Schema?</b></p> <ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l2 level1 lfo4;tab-stops:list .5in"><b>Simplicity:&nbsp;</b>It is easy to understand and use because everything is directly connected to the central fact table.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l2 level1 lfo4;tab-stops:list .5in"><b>Efficiency:&nbsp;</b>Queries (questions to the database) are faster because you don’t need to go through multiple layers of tables.</li> </ul> <p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal">In summary, a star schema organizes data in a simple and efficient way with a big central table (fact table) and smaller tables around it (dimension tables) that provide more details.</p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal"></p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>What is a Snowflake Schema?</b></p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal">A snowflake schema is a more detailed way to organize a database for analyzing data. It consists of:</p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>&nbsp;</b></p><ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l4 level1 lfo1;tab-stops:list .5in"><b>Central Table (Fact Table):</b> Just like in a star schema, there's a main table in the middle that holds the key data you want to analyze, like sales transactions. This table is called the "fact table."</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l4 level1 lfo1;tab-stops:list .5in"><b>Surrounding Tables (Dimension Tables):</b> Around this big table, you have smaller tables that provide more details about the data, like products, dates, and stores. These are called "dimension tables."</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l4 level1 lfo1;tab-stops:list .5in"><b>More Detailed Tables (Normalization):</b> In a snowflake schema, the dimension tables are further split into more tables. This is called "normalization." For example, instead of one big product table, you might have a product table split into product categories and subcategories.</li> </ul><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>How it Looks</b></p><ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l3 level1 lfo2;tab-stops:list .5in">The fact table connects to the dimension tables, and the dimension tables can connect to even more tables, making the shape look more like a snowflake.</li> </ul><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>Example</b></p><ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l2 level1 lfo3;tab-stops:list .5in"><b>Fact Table (Sales):</b> Contains information about each sale, like the amount sold, quantity, and sale date.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l2 level1 lfo3;tab-stops:list .5in"><b>Dimension Tables:</b></li> <ul type="circle"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level2 lfo3;tab-stops:list 1.0in"><b>Product Table:</b></li> <ul type="square"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level3 lfo3;tab-stops:list 1.5in">Split into:</li> <ul type="square"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level4 lfo3;tab-stops:list 2.0in"><b>Product Details Table:&nbsp;</b>Information about each product.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level4 lfo3;tab-stops:list 2.0in"><b>Category Table:&nbsp;</b>Categories of products.</li> </ul> </ul> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level2 lfo3;tab-stops:list 1.0in"><b>Date Table:</b></li> <ul type="square"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level3 lfo3;tab-stops:list 1.5in">Split into:</li> <ul type="square"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level4 lfo3;tab-stops:list 2.0in"><b>Year Table:&nbsp;</b>Information about years.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level4 lfo3;tab-stops:list 2.0in"><b>Month Table:&nbsp;</b>Information about months.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level4 lfo3;tab-stops:list 2.0in"><b>Day Table:&nbsp;</b>Information about days.</li> </ul> </ul> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt: auto;line-height:normal;mso-list:l2 level2 lfo3;tab-stops:list 1.0in"><b>Store Table:&nbsp;</b>Details about each store.</li> </ul> </ul><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>Why Use a Snowflake Schema?</b></p><ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l1 level1 lfo4;tab-stops:list .5in"><b>Reduced Redundancy:&nbsp;</b>It reduces duplication of data by splitting tables into more detailed tables.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l1 level1 lfo4;tab-stops:list .5in"><b>Storage Efficiency:&nbsp;</b>Takes up less storage space because similar data is grouped together.</li> </ul><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-outline-level:3"><b>Drawbacks</b></p><ul type="disc"> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l0 level1 lfo5;tab-stops:list .5in"><b>Complexity:&nbsp;</b>It can be more complex to understand and use because there are more tables to join.</li> <li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal;mso-list:l0 level1 lfo5;tab-stops:list .5in"><b>Query Complexity:&nbsp;</b>Queries can be slower and more complex because they have to join more tables.</li> </ul><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal"> </p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal">In summary, a snowflake schema organizes data in a detailed and efficient way by splitting tables into smaller related tables, reducing redundancy but increasing complexity. It looks like a snowflake because of its branching structure.</p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal"></p>Key Differences<ul><li><strong>Star Schema:</strong> Simpler to use, has fewer tables, more redundancy(repeated data), faster queries.</li><li><strong>Snowflake Schema:</strong> Complex, has&nbsp; more tables, less redundancy, slower queries.</li></ul><p>In essence, the star schema is simpler and easier to use, while the snowflake schema is more detailed and efficient in terms of storage.</p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal"></p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto; line-height:normal"></p>

  • 0 Comments
  • 81 Views
  • Share: