During our first week at the Dataschool, we were tasked with creating a schema for the Tableau Superstore. Schemas are an important step in the data journey as they provide the user with an understanding of the granularity of the data, or what each row represents. Furthermore, it allows the user to understand join behavior, knowing how tables and fields connect to each other, thus limiting the creation of redundant data. 

In the case of Tableau Superstore, the granularity of each row is the unique combination of Order ID and Product ID. This is because there can be multiple products per order, and multiple rows of data with the same Order ID but different Product_IDs. 

Regarding the Tableau Superstore Data, there are 19 fields:

Order ID: String

Order Date: Date

Ship Mode: String

Customer ID: String

Customer Name: String

Segment: String

Country/Region: String

City: String

State/Province: String

Postal Code: String

Region: String

Product ID: String

Category: String

Sub-Category: String

Product Name: String

Sales: Float

Quantity: Integer

Discount: Float

Profit: Float

Now, building the schema, I am going with a snowflake schema rather than a star schema, as our data has natural hierarchies, such as Category → Sub-Category → Product. These are better represented as separate tables than by flattening everything into a single wide dimension. You can read more about the differences in these blogs: 

Data Modeling: Unraveling Star Schema and Snowflake Schema

My First Week at Data School: Tables, Views, Keys and Schemas 

 Our fact table will include the fields, as they are foreign keys that connect to dimension tables: Order ID, Product ID, Customer ID, Ship ID, and Order Date ID. The fact table will also contain measurable, quantitative data, which includes Sales, Quantity, Discount, and Profit. This is exactly what is necessary in a fact table: quantitative measures and keys that provide additional context.

Now, looking at the snowflake branches, we will first look at Products. The first branch includes Product ID, Product Name, Category  ID and Subcategory ID. These then branch off using Category ID and Subcategory ID as primary keys. We do this because, instead of writing the full category name, it lets us write only the ID. Strings take up a lot more space than integers, and joining on integers is much faster than joining on strings.

Further looking into the Customer Branch, we connect this using the Customer ID, with Name and Postal Code ID and Customer Segment .We include Segment in the Customer tabl  as it describes the type of customer (Consumer, Corporate, Home Office) rather than a transactional detail. The Postal Code ID is further connected to the customer's location, which includes City, State, Region ID, and date (last updated). Country is stored here rather than in its own table, as in Superstore it will always be the United States. The reason we don’t store this together is that a customer can move, and thus you'd have to update every row tied to that customer. Keeping it separate means you just update the location record once. We keep the region as Region ID, as it is at a higher level in the geographic hierarchy. Multiple cities and postal codes can include the same region, so it makes sense and is more efficient to keep it as its own lookup table rather than repeating "East" or "West" on every row. Both the Postal Code and Region tables include a Date field to track when they were last updated.

Looking at Order Date, we connect this by using the key Order Date ID. We then break this down further into weekday, week, month, and quarter. This makes time-based analysis much faster and cleaner than parsing a raw date field every time. By keeping it in a separate table, we can compute the logic once and avoid re-querying it, while keeping the fact table clean and retaining only the most important metrics.

The final branch is Ship mode. This is connected to the fact table using Ship ID. We keep this in a separate lookup table so we don't repeat "First Class" or "Standard Class" on every row. 

Overall, building a schema is a worthwhile step. It forces you to truly understand your data structure, the relationships between tables, and what you actually plan to analyze. While Superstore comes as a flat file, designing this schema was a valuable exercise in thinking about how data should be structured before jumping into analysis.

If you want to take a look at the data, you can download it here.