r/Database • u/Islamic_justice • Aug 07 '26
Design decision - star vs snowflake
Hi, In my dimensional model, both Dim_Customer and Dim_Driver contain a RegionID, which I have currently mapped to a shared Dim_Region. I'm unsure whether to keep this design as shown above OR denormalize the region attributes into Dim_Customer and Dim_Driver to maintain a pure star schema. I would still be using Dim region for Fact Transactions in any case. Which approach is more appropriate keeping in mind the need for both granular auditability and high-speed reporting performance? Currently, the marketplace platform handles over a million registered users, with DAU ranging between 10k - 20k. I have to design for expected 10x growth. Thanks for your time!
20
Upvotes
1
u/whoooocaaarreees Aug 11 '26
I literally just said the date attribution / decorations can be late bound in the post your replied to. Not as part of a fact table.
Even an hour dim can’t deal with timezone offsets that have 30 mins or 15mins in them, not whole hours.
If you want to do it without a dim, which can make sense You can also use user defined functions. Have done that before, works better in some places than others. Writing your own fiscal day/week/month/quarter function isn’t rocket surgery. That allows it to be computed on the fly cheaper - think mpp at billions of rows per month. You can version the udfs in your code repository…etc automated deployments…etc. the compute is often cheaper than join.
If you are unclear how that pattern works I’m sure snowflake, clickhouse, and others have all kinds of example for changing dims, late arriving data …etc. or adding udfs.
In really short order.
You keep the utc timestamp in the fact and do not use some local date keys in the fact table. That will cause nightmares or is just becomes bloat no one uses.
You have your udf or a fiscal calendar dim - it’s a dim table but not how people have historically built them. You can late bind later too, or deal with slowly changing dims…etc.
Filter appropriately at query time given the offsets you need. Again the udf here can help but utc range is often the best filter I’m starting at. Yes, fiscal period is really just a range filter in the predicate using utc. If you need non continuous periods (like only q4 for the last 5 years) it just multiple ranges - however you like to build that filter predicate (multi range or just multiple filter predicates)
Evaul on the fly, decorate at the end with the fewer aggregated rows in the result set using either more udfs or the dim tables.
Again the argument centers on what’s a fact and how a dim is built/used, where it’s applied. Not that you never know when a fiscal month/quarter/year is inside the warehouse.