Ride-Hailing App ER diagram and database schema
The Ride-Hailing App database schema is a DB Planner template with 27 tables, 260 columns and 58 relationships, free to use. Core tables include dispatch_offers, driver_documents, driver_earnings, driver_location_pings. It can be opened as an interactive ER diagram or exported as PostgreSQL, MySQL, or SQL Server DDL.
- Tables
- 27
- Columns
- 260
- Relationships
- 58
- Category
- Logistics
- Exports
- DBML, SQL, C#
- Price
- Free
What this schema models
A complete ride-hailing app database design, modeled on how real ride-hailing platforms dispatch and price rides: 27 tables, 21 enums and 58 relationships covering markets, zones and product tiers, versioned rate cards and surge, riders and payment methods, ride requests, fare estimates and dispatch offers, trips, cancellations and two-way ratings, the itemized receipt, the driver earnings ledger and payouts, driver documents and vehicles, and online sessions with live location. THE FOUR DESIGN RULES 1. A REQUEST is not a TRIP. A ride request is the rider asking; a trip exists only once a driver accepts. Requests that find no driver, or are cancelled while searching, stay as requests, and counted per zone they are exactly the demand signal surge pricing needs. 2. Every dispatch offer is a row. Each driver offered the job gets a row that ends accepted, declined, expired or withdrawn, so acceptance rate is a query, and a partial unique index allows only one accepted offer per request: two drivers can never both win the same ride. 3. Prices are locked, then itemized. The fare estimate points at the exact rate card version and surge window it used and copies the multiplier; the trip keeps that multiplier, and the final fare is itemized lines (base, distance, time, surge, fees, tolls, promo, tip, tax). What the rider paid and what the driver earned are separate ledgers, so the platform take is the difference, never a stored column. 4. Latest position and location history are different tables. driver_locations holds one row per online driver, overwritten every few seconds and indexed with GiST for nearest-driver search; driver_location_pings is the append-only GPS stream, partitioned by day and dropped a partition at a time. Dispatch never reads the stream. DETAILS WORTH STEALING - Trips are a status machine with a timestamp per state (accepted, arrived, started, completed, cancelled), so pickup wait and ride time are plain subtractions. - Surge is stored per zone, tier and time window together with the open requests and available drivers that produced it, so any surged price can be explained in a dispute. - Zones are hexagonal grid cells, a fixed grid that keeps surge history comparable over time, and airport zones are flagged for queue-based dispatch. - Cancellations record who cancelled, why, how many seconds after acceptance (checked against the free cancellation window) and the share of the fee that compensates the driver. - Driver documents are reviewed one at a time with expiry dates, and a renewal is a new row, so the verification audit trail survives. - Payments carry an idempotency key, so a retry after a timeout can never charge a rider twice. WHAT YOU GET Clean DBML that imports directly into DB Planner, and a laid-out board with zones color-coded and framed: riders, markets and pricing, dispatch, trips, money, drivers and vehicles, and driver supply and location. Every table carries a note. Postgres-flavoured types, with PostGIS geography columns for locations; the rest ports cleanly to MySQL or SQL Server. Useful for developers building a ride-hailing, taxi or on-demand mobility app, and for students who need a realistic ride-hailing app ER diagram for a DBMS project. This is a schema design reference; fare regulation, driver classification and tax rules vary by market and belong in your own business logic.
Tables (27)
| Table | Columns |
|---|---|
| dispatch_offers | 11 |
| driver_documents | 12 |
| driver_earnings | 9 |
| driver_location_pings | 7 |
| driver_locations | 8 |
| driver_payouts | 12 |
| driver_sessions | 7 |
| drivers | 12 |
| fare_estimates | 15 |
| fare_line_items | 5 |
| fare_rules | 13 |
| payment_methods | 9 |
| payments | 12 |
| product_tiers | 7 |
| promo_codes | 11 |
| promo_redemptions | 6 |
| ratings | 6 |
| ride_requests | 15 |
| riders | 9 |
| saved_places | 5 |
| service_areas | 9 |
| surge_multipliers | 9 |
| trip_cancellations | 10 |
| trips | 21 |
| vehicle_product_tiers | 3 |
| vehicles | 12 |
| zones | 5 |
Relationships (58)
dispatch_offers.driver_id references drivers.idmany to onedispatch_offers.id references trips.dispatch_offer_idone to onedispatch_offers.ride_request_id references ride_requests.idmany to onedriver_documents.driver_id references drivers.idmany to onedriver_documents.vehicle_id references vehicles.idmany to onedriver_earnings.driver_id references drivers.idmany to onedriver_earnings.driver_payout_id references driver_payouts.idmany to onedriver_earnings.trip_cancellation_id references trip_cancellations.idmany to onedriver_earnings.trip_id references trips.idmany to onedriver_location_pings.driver_id references drivers.idmany to onedriver_location_pings.trip_id references trips.idmany to onedriver_locations.driver_session_id references driver_sessions.idmany to onedriver_locations.zone_id references zones.idmany to onedriver_payouts.driver_id references drivers.idmany to onedriver_sessions.driver_id references drivers.idmany to onedriver_sessions.service_area_id references service_areas.idmany to onedriver_sessions.vehicle_id references vehicles.idmany to onedrivers.id references driver_locations.driver_idone to onedrivers.service_area_id references service_areas.idmany to onefare_estimates.fare_rule_id references fare_rules.idmany to onefare_estimates.id references ride_requests.fare_estimate_idone to onefare_estimates.product_tier_id references product_tiers.idmany to onefare_estimates.rider_id references riders.idmany to onefare_estimates.surge_multiplier_id references surge_multipliers.idmany to onefare_line_items.trip_id references trips.idmany to onefare_rules.product_tier_id references product_tiers.idmany to onefare_rules.service_area_id references service_areas.idmany to onepayment_methods.rider_id references riders.idmany to onepayments.parent_payment_id references payments.idmany to onepayments.payment_method_id references payment_methods.idmany to onepayments.ride_request_id references ride_requests.idmany to onepayments.trip_id references trips.idmany to onepromo_codes.service_area_id references service_areas.idmany to onepromo_redemptions.promo_code_id references promo_codes.idmany to onepromo_redemptions.rider_id references riders.idmany to onepromo_redemptions.trip_id references trips.idmany to oneratings.trip_id references trips.idmany to oneride_requests.id references trips.ride_request_idone to oneride_requests.id references trip_cancellations.ride_request_idone to oneride_requests.payment_method_id references payment_methods.idmany to oneride_requests.pickup_zone_id references zones.idmany to oneride_requests.product_tier_id references product_tiers.idmany to oneride_requests.promo_redemption_id references promo_redemptions.idmany to oneride_requests.rider_id references riders.idmany to oneriders.home_service_area_id references service_areas.idmany to onesaved_places.rider_id references riders.idmany to onesurge_multipliers.product_tier_id references product_tiers.idmany to onesurge_multipliers.zone_id references zones.idmany to onetrips.driver_id references drivers.idmany to onetrips.fare_rule_id references fare_rules.idmany to onetrips.id references trip_cancellations.trip_idone to onetrips.product_tier_id references product_tiers.idmany to onetrips.rider_id references riders.idmany to onetrips.vehicle_id references vehicles.idmany to onevehicle_product_tiers.product_tier_id references product_tiers.idmany to onevehicle_product_tiers.vehicle_id references vehicles.idmany to onevehicles.driver_id references drivers.idmany to onezones.service_area_id references service_areas.idmany to one
How to use this template
- Open the ER diagram to see the tables and how they relate.
- Copy it into your workspace. You get your own editable copy, in DBML.
- Export it as PostgreSQL, MySQL, or SQL Server DDL, or as C# models.
The copy opens in DB Planner’s ER diagram tool, with the schema as text in the DBML editor beside it. Have a database already? Turn its SQL into an ER diagram instead.
Frequently asked questions
- What is in the Ride-Hailing App database schema?
- 27 tables and 58 relationships, across 260 columns. The table names and the full relationship list are shown on this page.
- Can I export it to PostgreSQL or MySQL?
- Yes. Every DB Planner template exports as DBML, as PostgreSQL, MySQL, or SQL Server DDL, and as C# models.
- Is this template free?
- Yes. You can open it in the browser without an account, and copy it into your own workspace with a free DB Planner account.
- Can I change it after copying it?
- Yes. A copy is yours: you can rename tables, add columns, and export it. Changes the author makes later do not affect your copy.