advancedTop 15 Database Design Questions
Design a warehouse inventory management system.
warehouses(id, name, location, capacity) products(id, sku UNIQUE, name, category, weight_kg DECIMAL) inventory(warehouse_id FK, product_id FK, quantity INT CHECK(quantity >= 0), reserved_qty INT DEFAULT 0, PRIMARY KEY(warehouse_id, product_id)) inventory_transactions(id BIGSERIAL, warehouse_id FK, product_id FK, quantity INT, txn_type VARCHAR, reference_id, created_at, created_by) EXCLUDE or CHECK
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