We have a project related to sales.
Now we save the stock of products in a separate table with the name Stock. During sales, sales-return, purchase and purchase-return stock tables will be updated. It works well, but while we delete or modify one of the sales or purchases, it is more difficult to maintain the stock.
I told my boss that we do not want to hold the stock in a separate table, but write a function to compute the stock from related tables ( sales, purchase, ...). Whenever the user wants to know the stock, they call the function to get the stock very easily. Thus, we do not need to think about stock maintenance. I think it is a good idea.
But he told me that if a lot of records come, the function will take longer and this will reduce the efficiency of the software. I don’t know if it is right or wrong. One thing I know is that it is against DB normalization. We do not need to store the calculated values in the table or outside it.
How can I create this database? Is another table better Stock?
source
share