Control virtual store stock

Asked

Viewed 259 times

-2

I am in a virtual store project and I have a question about the stock control process.

Initially I’m doing everything on the table product where I have two camps: manage_stock and stock. Manage Stock will control whether or not the product will have stock control at the time of sales and Stock is the stock in question.

When an order has its status marked as paid I direct decrease in the product in the column stock.

Follows structure of the table:

Tabela product
id    name      manage_stock    stock
1     Mouse     0               NULL
2     Teclado   1               50
3     Monitor   1               10
4     Gabinete  0               5

Table product

Is this logic correct? or should I create a table only for the stock linking the product. The drop in stock is a simple direct decrease in the table produtc?

  • If each product has a stock as well as a stock only has a product can soon have a column of stock in the product table itself

  • I voted to close as unclear because only with this information can only you answer this.

  • 1

    What information about logic should I include in the question? I passed the way I thought I was right and would like to know if I can improve the logic. @bigown your comment could be constructive if you indicated how I should improve the question or logic

  • Putting in more information, I have no way of knowing what you need, what you’re doing. At the moment the possible answer is that it may be better. The other way is to do a full tutorial on stock control that, in addition to making the question broad, may be of no use to this case. Stock control is often absurdly more complex than this. But if these are your requirements, it’s all right. Did it help you at all? I don’t think so. The question also doesn’t help to give another answer.

1 answer

1


My view of the context:

a table for products; A table for stock handling.

In the drive table you would control the inputs and exits of the products. Putting everything on a table will only generate difficulties of scalability of your application.

  • In case you’d get the table product and product_stock and for each product input or output I would have a new record in the table product_stock? To product_stock I will contain the columns id id_product qtd and type. The type column would define whether the movement is of type input or output. It would be that Luciano Bezerra?

  • Yes, it’s a valid approach, considering how little information we have about what you need.

  • Anyway your answer was very helpful.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.