Answer the question
In order to leave comments, you need to log in
There are 3 tables. Supplier, Goods. Order. How to find all vendor orders?
I develop the organization of database tables. I think to create the following 3 tables.
Suppliers:
id
name
Goods:
id
supplier id
price
Order:
id
product id
It is necessary to show the sum of all orders from the supplier of this product when issuing the goods:
Product: bag
Supplier: Zavod Bags LLC
This supplier had orders for: 500 750 rubles
Advise how to organize database tables? Wouldn't there be a big load if, at each delivery of goods, we search through all orders for the sum of all orders of the supplier?
Or is it better for the supplier to make the "sum of all orders" in the table and add the amount there with each purchase?
Or maybe there are other options for organizing database tables?
Answer the question
In order to leave comments, you need to log in
How can I find supplier orders if you sell goods from different suppliers and the goods in the order are from different ones? And who came up with such a wonderful structure?
Normal database structure. Just don't forget the date you placed your order. To simplify the task, you can also record the supplier's id in the order table.
Wouldn't there be a big load if, at each delivery of goods, we search through all orders for the sum of all orders of the supplier?
Or is it better for the supplier to make the "sum of all orders" in the table and add the amount there with each purchase?
The load will not be large with well-built indexes.
As for me, a completely non-normal structure: The
product, in principle, should not know anything about the supplier.
The price in the product table, the price of what? the cost of the goods from the supplier or what we will sell for? This field should not be present in the product
The order also does not need to know anything about the product.
According to me, the structure should be something like this:
Suppliers:
id
name
Products:
id
name
Order:
id
... (any common bullshit like date, etc.)
supplier id - if the order can be from only one supplier
Order_Position:
id
Order id
Supplier id - if each position of the order can be from different suppliers
Product id
Quantity
Price per item
This is an approximate structure and does not apply to issues of pricing, units of measurement, depreciation of goods, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question