advancedTop 15 Database Design Questions

Design a database for a ride-sharing platform (Uber-like).

users(id UUID, role CHECK IN ('rider','driver'), name, phone UNIQUE, email UNIQUE) vehicles(id, driver_id FK UNIQUE, plate UNIQUE, model, status) trips(id UUID PK, rider_id FK, driver_id FK NULLABLE, pickup_location POINT, dropoff_location POINT, status, fare DECIMAL, started_at, completed_at) trip_locations(trip_id FK, recorded_at TIMESTAMPTZ, location POINT, speed DECIMAL, PRIMARY KEY(trip_id, r

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Design a warehouse inventory management system.← Back to all SQL questions