Design the database for a food delivery app
PremiumDatabase designMedium
- Order state machine
- Menu versioning
- Geo queries
Quick answer
This database design interview question asks you to design the database for a food delivery app. Aim for a design that stores data correctly and serves its main queries well, then explain the schema, keys, indexes and trade-offs. Interviewers want to see how you model entities, choose keys and design for the real access patterns.
The problem
Design the database for a food delivery app like Swiggy or DoorDash. Customers browse nearby restaurants, order, pay and track the order; riders get assigned and deliver it. The hard parts are menus that change all day, orders that keep exactly what was ordered, valid status transitions and weekly payouts.
An order moves through accepted, preparing, picked up and delivered. Restaurants edit menus and prices all day and mark items out of stock. Riders go online, get assigned orders and drop them off. At the end of each week the platform pays restaurants and riders their share of every order.
What must the database for a food delivery app do?
- Order: Create an order with items and chosen options at the prices shown; the order must record exactly what was ordered even after the menu changes.
- Status: Move an order through placed, accepted, preparing, ready, picked_up, delivered or cancelled, with a timestamp for each step; only valid transitions are allowed.
How well must it do it?
- Snapshot correctness: An order shows the item names, options and prices at order time, forever.
- Valid transitions only: The database or the write path must reject an invalid status jump such as delivered after cancelled.
What scale should you design for?
Use these numbers in your estimates.
The scale numbers unlock with this questionUnlock
Key concepts
- Order state machine
- Menu versioning
- Geo queries
- Dispatch assignment
- Multi party orders
- Settlement
How you’ll practise
- Access patterns
- Entities
- Schema
- Indexes and queries
- Scale and consistency
- Wrap-up
Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.
What do interviewers look for?
In any database design round.
- Lists the entities and how they relate before writing tables
- Designs the schema around the main access patterns
- Chooses primary keys, foreign keys and indexes with reasons
- Explains where to normalise and where to denormalise
- Considers integrity, transactions and concurrent writes
- Plans for growth: partitioning, archiving and migrations
Questions people ask about this interview question
- Which design type is this question?
- It is a database design question. You design the database for a food delivery app and explain your choices the way you would in an interview.
- Is this question asked at entry level?
- It is marked Medium. Entry-level engineers can practise it, but it expects you to reason about requirements and trade-offs, not only list components.
- What should I cover first?
- Start with the entities and the main queries the database must answer. Agree on scope with the interviewer before you design anything.
- Can I practise it for free?
- It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.
Related questions
Updated · Written by the SevyDevy team