Sql Server Database Modeling

Asked

Viewed 88 times

0

Good morning friends,

I have a project that has basically two types of products, the simple products, such as market items, rice kg, beans 1 kg , etc.. and items composed as basic baskets , formed by simple items , ie within the basic basket we have rice, beans .. etc, I have a table that keeps the register of the simple products, I have another table that keeps the composite products and the simple products that are associated to it,and I also have a table that saves the history of outputs of the products,more in the case of a composite product it saves only the code of the same and the quantity that came out, how can I do at the time of exit of a composite product the simple items that form it are debited too , as I can model my bank for such ?

  • 1

    In infinite ways. The problem is that you are confusing domestic consumer items with sold items. In principle, when you buy a bag of beans to sell as a bean bag, you are only reselling. When you are putting a bag of beans in the basic basket, you are "consuming" that bag of beans, to "manufacture" a basic basket. A basic basket is not a composite product. It is a single item as well, which "spends" items from the stock when made. Consolidate the concepts before the modeling. Of course nothing forces you to do the way I said, but it should correspond to reality.

  • 1

    Think of your basket as a car. To make the car, you use bolts, tires, meters of wire, fabrics, switches. Who buys a car, and not a handful of parts. Who buys the parts is the factory, and she "spends" all when making the car. Eventually you buy separate parts from the factory, for replacement, and they can come from the same stock that came from the car. What changed was the fate of the piece (consumption, in the first case, sale, in the second case)

  • 2

    Applying to your case, a very simplified example would be: current stock: 30 bags of beans, 12 basic baskets. Manufactured 2 baskets (each with 2 bags of beans) consumed 4 items of stock, sold 3 separate bags, left 3 more units of stock. Current stock: 23 bean bags, 14 basic baskets.

No answers

Browser other questions tagged

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