D
D
drboboev2019-03-27 10:27:57
PHP
drboboev, 2019-03-27 10:27:57

How to implement a sales report with a changing hierarchy?

Good afternoon.
The task is as follows: It is
necessary to develop a system for tracking sales by territory. Every day, employees of their regions fill in the data, and the responsible officer collects this data and provides a report in the form of a hierarchy to the management.
At the moment, everything is implemented as a Nested set and everything is functioning quite successfully. But there was a problem with obtaining data for past periods. Because the structure often changes, and the report collects data based on the current structure.
I thought about making versions of the structure, that is, if the structure has changed, then the old structure is saved with the date by which it was relevant. Those. when loading old data, the old structure will be loaded. But it seems to me that this option is not suitable, because there will be porridge in the database, every time the structure changes, 100500 fields will be created to reflect the new structure.
Maybe someone had to do something similar, I will be glad to any advice.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
grinat, 2019-03-27
@grinat

Take mongo

P
Philipp, 2019-05-29
@zoonman

As a specialist in Monge, I will say - Monga is unnecessary here.
A report is usually a relatively static thing. Normally generated as a file, usually Excel, etc.
If your report is generated on the fly, then you need to change the approach to writing code and provide backward compatibility. This is realized through the correct choice of data structures and migrations (transformation of old data into new ones, with compatibility support).
There is an alternative option with creating snapshots, i.e. it simply makes a copy of the generated HTML page with all the embedded data and scripts. The approach is not very beautiful, but it is implemented faster than the others.
By the way, nothing prevents you from taking snapshots for Nested Sets and storing them in a separate table in the form of a forest of trees.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question