type
Post
Created date
Aug 9, 2022 02:58 AM
category
Data Science
tags
Data Warehousing
status
Published
Language
English
From
School
summary
slug
password
Author
Jason Ching Yuen Siu
Priority
Featured
Featured
Cover
Origin
Type
URL
Youtube
Youtube
icon
What is a snowflake?
A Hierarchy is formed -- which is snowflake -- when a dimension is broken down to two or more dimensions in a hierarchical manner.
What is a bridge table?
- is a table that links two dimensions, and only one of these two dimensions is linked to the fact. As a result, the star schema becomes a snowflake schema.
- A Bridge Table is also a snowflake, but the two dimensions that are linked through a Bridge Table. The relationship inbetween has a cardinality of 1-many and many-1.
When do we need a bridge table?
- Is needed when a dimension cannot be connected directly to the Fact as it has to go through another dimension.
For example, Dim-4b cannot
be connected directly to the fact without going through Dim-4a.
For example, Dim-4b cannot
be connected directly to the fact without going through Dim-4a. For Dim-4b to
be connected to Dim-4a, it has to go through a Bridge Table. This is because
the cardinality relationship between Dim-4a and Dim-4b is actually a many-many
relationship which is why a Bridge Table needs to be an intermediate table between
these two dimensions
Why does one dim cannot be DIRECTLY to the fact?
- (a) The Fact Table has a fact measure, and the dimension has a key identity. In order to connect a dimension to the Fact, the dimension’s key identity must contribute directly to the calculation of the fact measure. Unfortunately, this cannot happen if the operational database does not have this data.
- (b) The operational database does not have this data if the relationship between two entities in the operational database that hold the information about the dimension’s key identity and the intended fact measure is a <mark>many-many</mark> relationship
How to check if we need a bridge?
This question is asked to check if we need a bridge. There are 2 reasons:
- Is there a DIRECT relationship between dim and fact?
- Is Dim1 information available in Fact of a Dim2?
In principle, a Bridge Table is used:
(a) When it is impossible to have a dimension connected directly to the Fact Table, because simply there is no relationship between this dimension and the Fact Table (e.g. in the Product Sales case study, it is impossible to have a direct link from SupplierDim to ProductSalesFact)
(b) When an entity (which will become a dimension) has a many-many relationship with another entity (dimension) in the E/R schema of the operational database (e.g. Supplier and Stock has a many-many relationship).
(c) When the temporality aspect (data history) is maintained in the operational database and the Bridge Table can be used to accommodate a dimension that has temporal attributes (e.g. product supply history is maintained in the second snowflake schema example).
When a Bridge Table is used in the schema, there are two additional options:
(a) A Weight Factor is used to estimate the contribution of a dimension in the calculation of the fact measure. Because this is only an estimate, a weight factor is an option.
(b) Every snowflake schema (whether it has Weight Factor or not) can be implemented in two ways: a List Aggregate version and a non-List Aggregate version.
A case study about Product Sales:
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F7bc2abd2-b1e7-420b-bfa4-6006ee374e90%2FUntitled.png%3Ftable%3Dblock%26id%3D87f05331-0399-46a3-9950-c74a349cc724%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3Dq6HmPjGBnbwuQwm_LUSZx7aq6ijGznWMkInILRoWoh0?table=block&id=87f05331-0399-46a3-9950-c74a349cc724&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fa92f22d1-d07a-4ea3-829d-a535a2afe9d0%2FUntitled.png%3Ftable%3Dblock%26id%3D94d02e0d-53fa-4d77-a204-c93451ffadd3%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3D1WBLTeGgRckhUsGiaomtW7X5xpbziw-qRHk4abhwL5c?table=block&id=94d02e0d-53fa-4d77-a204-c93451ffadd3&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fc0f96ed7-5cb6-4276-81fa-5cf6b5c05671%2FUntitled.png%3Ftable%3Dblock%26id%3Db94637e7-0732-4ef5-858b-dd5c6358410e%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3D4UMolGjsJTShkoS0jIkE8gxo0tTa9rOMivRtlnXs4bM?table=block&id=b94637e7-0732-4ef5-858b-dd5c6358410e&cache=v2)
Why isn't this report correct?
- This report seems correct but it is impossible to be produced.
- Because in the E/R diagram, it shows that one supplier may supply many products (Many2Many) -- so the sales do not record which supplier supplied a product.
- Therefore, we can conclud that 1) there is no direct relationship between suppliers and total sales. 2) supplier information is not available in the sales of a particular product.
If the report is not correct, what should we do?
- We move the Supplier Dimension from being connected to the Fact and to create a relationship with the Product Dimension — that means we added a Bridge Table between Product Dimension and Supplier Dimension.
- The bridge table has three information in which we can “drill down” for information on products: location, date and quantity of supplies.
Why are there three kinds of representations? What is the difference?
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fe679fbe2-a584-41af-9f5b-656f4a76f9df%2FUntitled.png%3Ftable%3Dblock%26id%3D09c2350f-d69a-4536-add1-e21e3373c1a9%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DtPJl1rQyXkhC2CqfaEikzE94mcP8sgyjkHArVsfJrV0?table=block&id=09c2350f-d69a-4536-add1-e21e3373c1a9&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F7e9f360d-bca8-40c0-afa3-d21d8c4dbccc%2FUntitled.png%3Ftable%3Dblock%26id%3D7818d59a-46ab-4839-a247-2207debe2e3e%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DNfGKOZb2Zr1ie9y-0ACylXRTJuTt43BThNgjqYJMrJU?table=block&id=7818d59a-46ab-4839-a247-2207debe2e3e&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F606bd78e-49c4-4b09-8985-506084993ccd%2FUntitled.png%3Ftable%3Dblock%26id%3D686fcba7-2b43-4199-8a18-5bdba1cfc7e5%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DCkDWiKWIzuyRfv84r_oBC5ZPBjsdS1vEPLQ28R0oJt8?table=block&id=686fcba7-2b43-4199-8a18-5bdba1cfc7e5&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Ff6ab04fc-f3c2-48df-8210-579702c91073%2FUntitled.png%3Ftable%3Dblock%26id%3D1ca76f9e-2876-474b-86c9-986c67ae0de6%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3D78eS15j0-cI6VWLAk8TxSptGt9Ih9_tmCdMB4OXlCjw?table=block&id=1ca76f9e-2876-474b-86c9-986c67ae0de6&cache=v2)
Figure 5.7 for further details. 5.7 is where you — as the manager —want to see the detail of the dim that cannot be directly connected (i.e., Supplier). For example, we know that product A is performing particularly well, and we want to further information about details of the supply history and the suppliers.
Figure 5.8 for temporal dim. 5.8 is where the operational database does not maintain a master list of all suppliers (assume that each supplier may supply any product in an ad hoc manner), we will not have the Supplier Dimension in the schema in the figure 5.8. Instead, we will only have the Bridge Table; however, for each Product-Supplier pair, we will have Location and Date implemented as a weak entity, because for each productsupplier, there are multiple supplies.
Therefore, the Bridge Table here acts as a temporal dimension. This means, for each product, there is a list of the history of supplies.
Figure 5.9 for non-temporal warehouse. 5.9 is where the history is not needed (in a non-temporal data warehouse). You can see that the Product Supplier Bridge Table will only have ProductNo and SupplierName attributes, without the history of supplies.
A Truck Delivery Case Study
A trucking company is responsible for picking up goods from the warehouses of a retail chain company and delivering the goods to individual retail stores. A truck carries goods on a single trip, which is identified by TripID and delivers these goods to multiple stores. Trucks have different capacities for both the volumes they can hold and the weights they can carry.
Currently, a truck makes several trips each week. An operational database is being used to keep track of the deliveries, including the scheduling of trucks to provide timely deliveries to stores.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2F41b604a7-0016-4aeb-84d4-a583e3942df7%2FUntitled.png%3Ftable%3Dblock%26id%3Deb975733-0fe0-484c-aea1-0b4d2a2bd960%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DcTJMu043znStElOaqC73JCRikXQhBK3_MVy66fyHqJk?table=block&id=eb975733-0fe0-484c-aea1-0b4d2a2bd960&cache=v2)
(i) a trip may pick up goods from many warehouses (i.e. a many-many relationship between Warehouse and Trip);
(ii) a trip uses one truck only, and obviously a truck may have many trips in the history (i.e. a many1 relationship between Trip and Truck);
(iii) a trip delivers goods (e.g. TVs, fridges, etc.) potentially to several stores (a many-many relationship between Trip and Store, which is represented by the Destination table)
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fb35092a2-f307-418e-8400-28442b6b9d14%2FUntitled.png%3Ftable%3Dblock%26id%3Dc1af92af-c2ab-4d4f-ae21-391437683614%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DyIrhFBbAE3bpRIhovIlxxVKF2gpoYR_caYBTD2TQZq8?table=block&id=c1af92af-c2ab-4d4f-ae21-391437683614&cache=v2)
Why isn't this report correct?
If you look at the Tables 5.9, 5.10, 5.11, 5.12, 5.13, and 5.14, you will see that there is no direct relationship between Store and Total Delivery Cost in the Fact Table.
This is due to the many-many relationship between the Trip entity and Store entity in the E/R diagram of the operational database.
If the report is not correct, what should we do?
To solve this problem, a Bridge Table can be used, as shown in Fig. 5.12.
![notion image](https://www.notion.so/image/https%3A%2F%2Ffile.notion.so%2Ff%2Ff%2Fe1c5ba0e-562a-49b0-8505-ce5e38fc061b%2Fbc8d79c2-417a-47b5-b3aa-e0826c8544ea%2FUntitled.png%3Ftable%3Dblock%26id%3D3325cbbe-abaa-452a-b92f-fff594e86b1b%26spaceId%3De1c5ba0e-562a-49b0-8505-ce5e38fc061b%26expirationTimestamp%3D1725818400000%26signature%3DCh9c2jjQ3K4SuvuFqzjjlPqdprsGHwvR7inGTXi1EFk?table=block&id=3325cbbe-abaa-452a-b92f-fff594e86b1b&cache=v2)
- Author:Jason Siu
- URL:https://jason-siu.com/69a5349b59a0462cb69d02c979231cff
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts