Database Design: inventory and sales system?

后端 未结 2 877
孤街浪徒
孤街浪徒 2020-12-12 15:33

I need to develop a inventory and sales system.

For inventory, I need to be able to keep track of ideal stock levels, current stock levels, reorder point, cost, sell

2条回答
  •  难免孤独
    2020-12-12 16:05

    I would suggest completely separating the inventory tables from the money accounting tables. For example, the example you gave I know to be ridiculous: For your average fast food restaurant a $.90 cent Coke costs about $.05-$.07 for the cup, and less than a penny for the liquid, leaving a tidy profit of $.83ish. Why do the costs have to add up to $.90?

    Tables:

    InventoryItems fields: InventoryItemId, Name, CurrentInventoryLevel, IdealInventoryLevel

    InventoryChangeRecords fields: InventoryChangeId, InventoryItemId, Change (int)

    RetailItems fields: RetailItemId, Name, Price

    RetailItemMakeup fields: RetailItemId, InventoryItemId, Quantity

    SaleTransactions fields: SaleTransactionId, DateTime, TotalSale

    SaleTransactionItems fields: SaleTransactionId, RetailItemId, Quantity

    For each sale, you should use a sproc (or trigger) to update CurrentInventoryLevel, and insert records into InventoryChangeRecords. You can easily figure out how any sale impacted inventory by joining from SaleTransaction to SaleTransactionItems to RetailItemMakeup.

    If you wanted to do it in an even stronger (but IMO extraneous) manner, you could create another many-to-many table between SaleTransactionItems and InventoryChangeRecords.

提交回复
热议问题