简体   繁体   中英

Database structure for Inventory System

I am trying to develop an inventory and point of sale system for a computer shop. Most of their have product serial numbers but some products (eg Flash drive) do not. When they are about to sell any product they want to fetch the product information from the inventory by the "product's serial number" and for those products which do not have serial numbers they will select the product information from dropdown list.

I have design the database for keeping the inventory information but I am really confused about how to keep the serial numbers. Could you please give me your suggestion on a better way to structure my database for keeping information of products with and without serial numbers

Thanks:)

Table: category

category_id category_name

Table: brand

brand_id brand_name

Table: product

product_id  category_id   brand_id   product_name

Table: purchase_order

p_order_id supplier_id total_amount  purchase_date

Table: purchase_details

p_details_id  p_order_id   product_id   unit_price   quantity

Table: inventory_transaction (this tbl is for keeping track of current stock, for every purchase I add positive values and for purchase return I add negative values)

inv_tran_id    product_id   unit_price  quantity

edit

When I fill up my database table it looks like following:

Table: product

product_id  category_id   brand_id   product_name
   1            1          2           17 Inch LCD LED
   2            2          5           8 GB Flash Drive

purchase_order

p_order_id supplier_id total_amount  purchase_date
  1            1         500.00        2012-12-15 

Table: purchase_details

p_details_id  p_order_id   product_id   unit_price   quantity
   1             1            1           200.00        10
   2             1            2           50.00          5

You've kinda answered your own question when you say product's serial number A product's number would be associated with the Product entity and should be on the Product table. That's assuming the Product serial Number is unique to the product.

A manufacturer's product serial number would not be unique and so would have a many to one relationship with the Product. This would have to held on another table perhaps called the Product_Item or Manufacturer_Product with the Manufacturer's Product Serial Number as Primary key and the Product_ID as a Foreign key. You could extend this out to define other Manufacturer attributes such as the Manufacturer's Product name (which may be different) and onwards to the Manufacturer itself. You'd have to do this anyway if you want to do any kind of automated stock level control via inventory ordering.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM