Answer the question
In order to leave comments, you need to log in
How to organize a database to store sales with a hierarchy?
Good afternoon.
There is a task - there are a large number of outlets scattered throughout Russia. It is necessary to make an application into which sales will be entered daily by points. Everything is complicated by the fact that these points must be grouped - direction-> region, region-> city-> trading_point.
What came to mind is to store the structure according to the nested sets model in one table, and store sales with the point identifier in another table.
There is also an option to store the structure according to the parent-> child model, in another table to also store sales with the point identifier, collect data with a recursive query, which forces you to use PostgreSQL or engage in recursion in the application code, which is not good.
Both options have their pros and cons, perhaps someone will be able to offer something neutral that will solve the problems of both approaches.
Thanks in advance.
PS You should also take care of displaying all this "nightmare" to the user, which should also be taken into account when choosing an approach.
PPS Server language - PHP.
Answer the question
In order to leave comments, you need to log in
ugums, indicate to each outlet explicitly both the region and the region and the city. well, in the next table in the type of sale you need by points. in this case, for further simplicity of reporting, this is justified
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question