Data Mart Design
Business Questions This Enables:
- •How did station closures affect ridership patterns?
- •What was the average trip duration when a station had 15 docks vs 10 docks?
- •Which subscriber types used stations before vs after status changes?
Key Challenge
Station attributes (status, dock count) change over time, but source data only shows the current state. We need to preserve historical versions to analyze trips accurately.
bikeshare_tripsRaw trip events
bikeshare_stationsStation metadata
stg_bikeshare_tripsCleaned trips with date parts
snap_bikeshare_stationsSCD2 station history
dim_stations_scdStation dimension with versions
fct_trips_with_station_historyTrip facts with historical context
Trip Data Path
Raw trip records from BigQuery public dataset. Each row is one bike rental.
Trip facts joined with historical station data. Station attributes are AS OF trip date.
Station Data Path (with SCD2 history)
Station metadata. Contains current state only - no history.
Station dimension with full version history (SCD Type 2). Multiple rows per station.
KPI Measures (from Fact Table)
trip_countCOUNT(*)Total number of trips
avg_durationAVG(duration_minutes)Average trip length in minutes
peak_hour_tripsCOUNT(*) WHERE start_hour BETWEEN 7 AND 9Morning rush hour trips
subscriber_ratioCOUNT(subscriber_type=Annual) / COUNT(*)Percentage of annual subscribers
Data Flow Summary
| trip_id | start_time | start_station_id | subscriber_type | duration_minutes |
|---|---|---|---|---|
| 9900001 | 2019-06-15 09:30:00 | 2575 | Annual | 12 |
| 9900002 | 2021-02-20 14:15:00 | 2712 | Walk Up | 8 |
| 9900003 | 2020-08-10 11:00:00 | 2575 | Local365 | 25 |
| station_id | name | status | number_of_docks | modified_date |
|---|---|---|---|---|
| 2575 | 5th & Bowie | active | 15 | 2020-06-15 |
| 2712 | Toomey Rd @ S. Lamar | closed | 13 | 2021-01-10 |
| trip_id | trip_date | subscriber_type | start_station_id | start_station_name | start_station_status_at_trip | start_station_docks_at_trip |
|---|---|---|---|---|---|---|
| 9900001 | 2019-06-15 | Annual | 2575 | 5th & Bowie | active | 15 |
| 9900002 | 2021-02-20 | Walk Up | 2712 | Toomey Rd @ S. Lamar | closed | 13 |
| 9900003 | 2020-08-10 | Local365 | 2575 | 5th & Bowie | active | 15 |