Looks like a fact-less fact but walks like an attribute
2 posters
Page 1 of 1
Looks like a fact-less fact but walks like an attribute
I have a table which represents fleet vehicles. Those vehicles can be assigned to a driver which is the primary driver for an extended period of time on the vehicle. This feels like a fact table:
fact_driver_assignment
* assignment_date_id (dim_date)
* vehicle_id (dim_vehicle)
* driver_id (dim_drivers)
however, my dim_drivers table would have only 3 columns because the data for driver is basically just a lookup table in the source system:
dim_driver
* id
* driver_key (ID in source system)
* driver_name
In addition, I would like to be able to key off of something like dim_vehicle.is_assigned_to_driver for my queries, which makes me feel like maybe I should put the assigned driver in my dim_vehicle table as an SCD Type 2 like so:
dim_vehicle
* id
* vehicle_key
* is_assigned_to_driver
* driver_assigned
* driver_assigned_on_date
* etc.
How should this assignment be represented if I want to use that assignment as part of my query predicate when filtering dim_vehicle? Would it be appropriate to store the actual assigned driver on dim_vehicle?
Your input is greatly appreciated.
fact_driver_assignment
* assignment_date_id (dim_date)
* vehicle_id (dim_vehicle)
* driver_id (dim_drivers)
however, my dim_drivers table would have only 3 columns because the data for driver is basically just a lookup table in the source system:
dim_driver
* id
* driver_key (ID in source system)
* driver_name
In addition, I would like to be able to key off of something like dim_vehicle.is_assigned_to_driver for my queries, which makes me feel like maybe I should put the assigned driver in my dim_vehicle table as an SCD Type 2 like so:
dim_vehicle
* id
* vehicle_key
* is_assigned_to_driver
* driver_assigned
* driver_assigned_on_date
* etc.
How should this assignment be represented if I want to use that assignment as part of my query predicate when filtering dim_vehicle? Would it be appropriate to store the actual assigned driver on dim_vehicle?
Your input is greatly appreciated.
ryno1234- Posts : 33
Join date : 2015-01-07
Re: Looks like a fact-less fact but walks like an attribute
I would have begin and end dates in the driver assignment fact and not put driver information in the vehicle dimension. Then it is real easy to query which vehicles are assigned at any point in time.
Re: Looks like a fact-less fact but walks like an attribute
Thank you, as always ngalemmo.
How would I go about querying if a given vehicle is currently assigned (regardless of who it's assigned to) when using the vehicle in other fact queries.
For example, if I had (along with the requisite dimensions):
fact_vehicle_driver_assignment
* id
* date_id (D)
* vehicle_id (D)
* driver_id (D)
* start_date
* end_date
fact_vehicle_mileage_checkin
* id
* date_id (D)
* vehicle_id (D)
* latest_mileage_reading (M)
How would I go about querying fact_vehicle_mileage_checkin for vehicles which are unassigned without doing a fact-to-fact table join (which I've thus far avoided like the plague)?
This is why I have thought that I must have my attribute of whether or not the vehicle is assigned as an SCD Type 2 in the dim_vehicle table. How would I address this need?
How would I go about querying if a given vehicle is currently assigned (regardless of who it's assigned to) when using the vehicle in other fact queries.
For example, if I had (along with the requisite dimensions):
fact_vehicle_driver_assignment
* id
* date_id (D)
* vehicle_id (D)
* driver_id (D)
* start_date
* end_date
fact_vehicle_mileage_checkin
* id
* date_id (D)
* vehicle_id (D)
* latest_mileage_reading (M)
How would I go about querying fact_vehicle_mileage_checkin for vehicles which are unassigned without doing a fact-to-fact table join (which I've thus far avoided like the plague)?
This is why I have thought that I must have my attribute of whether or not the vehicle is assigned as an SCD Type 2 in the dim_vehicle table. How would I address this need?
ryno1234- Posts : 33
Join date : 2015-01-07
Re: Looks like a fact-less fact but walks like an attribute
Ok, fair enough. Given that use case it makes sense to store assignment information in the vehicle dimension.

» Single Attribute Dimensions - why not instead write textual attribute into Fact table?
» Dimension Attribute or Fact Attribute
» Dimension Attribute vs Fact Table Key
» Can a 'fact grain' attribute be null?
» dimension attribute denormalisation in fact table
» Dimension Attribute or Fact Attribute
» Dimension Attribute vs Fact Table Key
» Can a 'fact grain' attribute be null?
» dimension attribute denormalisation in fact table
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|