参考回答
This is a scenario-based question. Walk through your thinking:
- Identify the business process: Rides connecting riders with drivers
- Identify the grain: One row per ride
- Identify dimensions: rider, driver, vehicle, pickup_location, dropoff_location, date/time
- Identify facts/measures: fare, distance, duration, tip, surge_multiplier
-- Fact table
CREATE TABLE fact_rides (
ride_id BIGINT PRIMARY KEY,
rider_id INT,
driver_id INT,
vehicle_id INT,
pickup_location_id INT,
dropoff_location_id INT,
ride_start_datetime TIMESTAMP,
ride_end_datetime TIMESTAMP,
distance_miles DECIMAL(10,2),
duration_minutes INT,
base_fare DECIMAL(10,2),
surge_multiplier DECIMAL(3,2),
tip_amount DECIMAL(10,2),
total_fare DECIMAL(10,2)
);
-- Dimension tables
CREATE TABLE dim_rider (...);
CREATE TABLE dim_driver (...);
CREATE TABLE dim_vehicle (...);
CREATE TABLE dim_location (...);
Why interviewers ask this: This tests whether you can apply theoretical knowledge to real scenarios. They want to see your thought process, not just the final answer.