I am trying to create a small database to manage my small business.
What is the best parasitic to put my product stock quantity in the database? I already thought of two ways below
product
table
id, code_bar, weight,...
First approach product_stock
id, product FK
, buying_price, quantity..
Example insert in the table product_stock
for the product
number 1
id:1, product: 1 FK
, buying_price:2, quantity:5
For this approach i simply declare that i have five items of the product 1
Second approach product_stock
Example insert in the table product_stock
for the product
number 1
id:1, product: 1 FK
, buying_price:2
id:2, product: 1 FK
, buying_price:2
id:3, product: 1 FK
, buying_price:2
id:4, product: 1 FK
, buying_price:2
id:5, product: 1 FK
, buying_price:2
In this approach I insert 5 lines to describe how many items I have for product 1
The more typical method is to include a quantity
column in the product_stock
table.
However, under some circumstances, having row in the database for every item of stock can be useful. After all, each item could have different characteristics:
If it is important to track such information, then a separate row per item could be helpful.
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.