Reputation: 13
I'm trying to understand the logic on how dim tables are connected with Fact tables.
I currently have a fact table that has no data and have two Dim Tables that have data.
Dim Table 1 : Suburbs
Dim Table 2 : Restaurants
As Dim table have different number of rows. How do I make the Fact table link the Dim table with the suburbs and Restaurants that shows the correct order/results?
Upvotes: 0
Views: 411
Reputation: 12989
The data stored in fact, determines the granularity of the facts. The granularity of facts decide the granularity of dimension tables.
E.g., Suburbs is a dimension : Holds the suburb details
Restaurants is a dimension : Holds the Restaurant details
FactRestaurantSales is a Fact : Holds the sales at Restaurant granularity level.
1 Pizza of $20 dollars were sold in a restaurant Pizza Garden in suburb Bellevue, will be stored as below:
DimSuburb:
+-------------+------------+
| DimsuburbId | Suburbname |
+-------------+------------+
| 1 | Bellevue |
+-------------+------------+
DimRestaurant:
+-----------------+----------------+
| DimRestaurantId | RestaurantName |
+-----------------+----------------+
| 1 | Pizza Garden |
+-----------------+----------------+
DimItem;
+-----------+----------+
| DimItemId | ItemName |
+-----------+----------+
| 1 | Pizza |
+-----------+----------+
FactRestaurantSales :
+-----------------------+--------------+-----------------+---------+-------------+----------------+
| FactRestaurantSalesId | DimSuburbId | DimRestaurantId | DimItem | DollarSales | QuantitySales |
+-----------------------+--------------+-----------------+---------+-------------+----------------+
| 1 | 1 | 1 | 1 | 20 | 1 |
+-----------------------+--------------+-----------------+---------+-------------+----------------+
Upvotes: 1