S
S
sangan2018-12-05 00:18:55
MySQL
sangan, 2018-12-05 00:18:55

How to store a history of availability and receipts / expenses in mysql?

It is necessary to organize the creation and storage of data on the php + mysql site:
- actual availability, which can be changed manually (model, size, color, quantity)
- receipts (model, size, color, quantity)
- expenses (model, size, color, quantity , price)
- the ability to generate a reporting table in a given time interval, for example, a month.
1. How to properly organize data storage, taking into account the fact that there can be several manual receipts, expenses and changes in availability per day and each operation can contain dozens of lines?
My idea is to keep the actual presence, each time overwriting it after the operation. Store manual availability changes as separate receipts/withdrawals. Monthly create a model availability log, and if necessary, build a report, take the nearest availability log and calculate operations from it in a given interval.
2. How to store the history of availability, if the price of the goods can be different depending on the time of arrival at the warehouse?
For example, there may be a situation when there are 100 models in stock, 10 sizes, 10 colors, 30 pieces each, for a total of 300,000 items. Store in delimited strings? In files?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
stratosmi, 2018-12-05
@stratosmi

Everything has already been invented for us.
You are interested in "tables of balances and turnovers" or "tables of movements and totals" for "Registers of accumulation"
cascade-group.com.ua/fizicheskaya-struktura-bazy-1s
devel1c.blogspot.com/2013/06/ blog-post_16.html

D
Dmitry, 2018-12-05
@dimoff66

models
id
name
id
type (inflow, outflow)
date
model_id
size
color
amount
price
rests Product balances (log)
month
model_id
size
color
movement_id (stored in the movement id section to get the delivery price)
amount

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question