Ride-hailing trip grain
Model rides where one customer trip can split into multiple priced segments for pooling, stops, and driver handoffs.
Concept
fact-table-grain
The primary modeling idea this problem reinforces.
Requirements
4
Business needs the model must satisfy.
A ride-hailing marketplace is adding pooled rides and scheduled stops. Finance needs fare, incentive, and distance analysis by segment because a single trip can involve multiple priced legs and sometimes more than one driver.
Trip-grain facts look simple until one trip has multiple economically meaningful legs. Choosing the wrong grain forces analysts to average segment-level measures or duplicate dimensions in ways that make driver payouts and marketplace margin unreliable.
- Create a fact table where one row represents one trip segment.
- Keep both the source trip id and segment id queryable on the fact.
- Add fare and segment-time fields at the segment grain.
- Declare relationships from the segment fact to rider and driver dimensions.
Template
Ride-hailing trip starter workspace
The model users start from in the full workspace.
Entities
2
Seeded tables visible in the public preview.
Dialect
postgresql
Generated SQL target for this starter model.
This preview is read-only. Open the workspace to edit and verify; saving needs a free account.
Open workspaceTry the question first.
The discussion has other people's approaches and solutions. Give it a real attempt before you read them.