I am new to data warehousing (having learnt this in my school days) and is looking to do a data warehouse as a side project. Below is a simple data warehouse design I came up with:
The data warehouse have 2 dimension tables and 1 fact table. 1 dimension table contains datetime data and the other contain the device data. The fact table contains the device incoming data values captured at the field. The data granularity in the fact table is 5 minutes.
I am confused on how time-series is being handled and will appreciate if someone can clarify this. Assuming one row of data coming from the device looks like this:
datetime drive_a drive_b drive_c shaft_a shaft_b shaft_c total_output
02/01/2022 13:05 4.2 3.2 7.4 5.3 8.2 6.4 4563.2
This will be processed and stored into the fact table in the data warehouse.
How do I handle the datetime
column from this incoming data since the dateKey
is not the same format as the datetime
incoming data?
I am thinking that the fact table need another column called dateTime_raw
, but that defeat the purpose of a dim_datetime
table isn't it since my datetime is already in my fact table?
P.S: Sorry if my question is confusing; trying my best to explain since I am not proficient in this field.
dateKey
? Yourdim_datetime
table will essentially need a field that has the same granularity of dates and times as yourfact_deviceValues
so you can relate the two together. By your example, it looks like that granularity is to the minute.dateKey
to uniquely identify each row. I do not understand what you mean by same granularity of dates and times. Currently I do not have a field for this datetime in the fact table (this is one of the part I am confused if its needed). Am I right to saydim_datetime
should not have seconds field? Should I keep the datetime data string as it is in the fact table (if so, how does this field works withdim_datetime
, rather what is the purpose ofdim_datetime
in the first place?)? Appreciate if you have some examples. Thanks!datetime
field even though your picture doesn't show that? Your example also shows thatdatetime
field has hours and minutes but not seconds. So yourdim_datetime
table should storedatetime
s with hours and minutes (doesn't need seconds) as a single field, to make joining easier.datetime
field because I am confused at whether it needs to have (I figured now that this field is a must). Indim_datetime
, I should have adatetime
that is in the same format as the one in my fact table? Therefore thedim_datetime
will have a FKdatetime
from fact table (all other fields remain the same as per example?)? Does it make sense to still have the hour, minutes indim_datetime
?