Bird
0
0

You are designing an inventory system that must handle multiple warehouses. Which design approach best ensures accurate stock counts across warehouses and prevents overselling?

hard📝 Trade-off Q15 of 15
LLD - Design — Online Shopping Cart
You are designing an inventory system that must handle multiple warehouses. Which design approach best ensures accurate stock counts across warehouses and prevents overselling?
AMaintain separate stock counts per warehouse and use transactions to update atomically
BKeep a single global stock count without warehouse details
CUpdate stock counts asynchronously without locking
DAllow negative stock counts to handle overselling
Step-by-Step Solution
Solution:
  1. Step 1: Consider multi-warehouse stock tracking

    Each warehouse should have its own stock count to track inventory accurately.
  2. Step 2: Ensure atomic updates to prevent overselling

    Using transactions or locks ensures stock updates are consistent and prevent race conditions.
  3. Final Answer:

    Maintain separate stock counts per warehouse and use transactions to update atomically -> Option A
  4. Quick Check:

    Atomic updates + per-warehouse stock = accurate inventory [OK]
Quick Trick: Use atomic transactions and per-warehouse counts [OK]
Common Mistakes:
  • Using global stock ignores warehouse differences
  • Updating asynchronously causes race conditions
  • Allowing negative stock hides overselling problems

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes