简体   繁体   English

库存系统的数据库结构

[英]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 表格:purchase_order

p_order_id supplier_id total_amount  purchase_date

Table: purchase_details 表格: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) 表:inventory_transaction(此tbl用于跟踪当前库存,为每笔采购我添加正值,为采购退货我添加负值)

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 表格: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. 当您说product's serial number时,您已经回答了您自己的问题。 product's serial number号将与Product实体相关联,并且应在Product表中。 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. 这必须保留在另一个表上,该表可能称为Product_Item或Manufacturer_Product,其中制造商的产品序列号为主键,而Product_ID为外键。 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. 如果要通过库存订购执行任何类型的自动化库存水平控制,则无论如何都必须这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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