Design a Database Schema for an E-Commerce Website

viaLeetCode

Requirements: Design the database schema for an e-commerce website with no fixed constraints given by the interviewer — the candidate is expected to surface and reason about bottlenecks themselves. Scenarios to account for:

  • Ordering products
  • Clients having multiple delivery addresses
  • Multiple sellers, with the same product sellable by more than one seller
  • Order tracking / order status
  • Registering a new product
  • Inventory tracking per seller
  • Product search
  • Shopping cart containing products from different sellers

Design: Core tables typically include Users, Addresses (1-to-many with Users), Sellers, Products, ProductListings (seller-product-price-inventory join), Orders, OrderItems, OrderStatusHistory, and Cart/CartItems. Key discussion points: normalizing product vs listing data so the same product can map to multiple sellers, indexing for search, and how order status transitions are tracked and audited.

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account