Home > database >  In SQL according to the order distribution of inventory
In SQL according to the order distribution of inventory

Time:10-28

There are three form
Table1 (factory information) : storage plant, materials, production date, quantity, a factory can be delivered on the same date of different material
Table2 (order information) : storage company name, the material name, expected delivery date, purchase quantity
Table3 (supply relationship, record to which factories which companies can buy what material) : store order company name, factory name, the material name

Table 1
The factory material quantity date
1 a 100 2010-10-10
1 b 200 2010-10-10
1 a 500 2011-11-11
2 a 300 2010-10-10
.

Table 2
Company material quantity date
C1 a 100 2010-10-12
C2 200 2010-10-10 b
C1 a 500 2011-11-11
C3 a 300 2010-10-10
.

Table 3
Company factory material
1 a c1
C1 2 a
C2 1 b
C3 2 a
.


If the same delivery time demand is less than the supply, a large quantity of plant selection priority to meet company, factory production date & lt;=company expected delivery date

O
Each company in the expected delivery date can get how much material from which factory, following structure
The factory company material date
1 c1 100 2010-10-10
.

CodePudding user response:

Data is too much demand please attach table test data
  • Related