Skip to content
Back to challenges
Grain and KeysConcept Challengeintermediate20 min

Ride-hailing trip grain

Model rides where one customer trip can split into multiple priced segments for pooling, stops, and driver handoffs.

How this preview works
Preview this problem before signing in. Sign in to save progress and submit work.

Concept

fact-table-grain

The primary modeling idea this problem reinforces.

Requirements

4

Business needs the model must satisfy.

Read the concept guide: Fact table grain
Scenario

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.

Why this matters

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.

Requirements
  • 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.
Read-only starter workspace
Inspect the authored starting ERD, then open the workspace to edit and run the checks. Saving your progress needs a free account.

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.

Mini Map

This preview is read-only. Open the workspace to edit and verify; saving needs a free account.

Open workspace

Try the question first.

The discussion has other people's approaches and solutions. Give it a real attempt before you read them.