J
J
JTester2022-01-08 04:52:20
Database design
JTester, 2022-01-08 04:52:20

How does statistics work?

How do daily, monthly and general statistics work? Which column should be the main column in the database? How to implement it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2022-01-08
@JTester

there is just a log.
and statistics - a selection from this log, aggregated according to certain criteria.
in your variant - sampling for the certain period.

N
Nikolay Savelyev, 2022-01-08
@AgentSmith

Which column should be the main one in the database? How to implement such a stat?))

There are no columns in the database. The database has tables, procedures, triggers,... This is if we are talking about relational databases, not NoSql.
The columns are in the database table.
And in the table, the main column is usually id.
What is the statistics here?

M
Myclass, 2022-01-11
@Myclass

I understand that the author of the question is new to these topics, and I think it will not work, but I will try to explain in a nutshell. There was a free minute...
There are different approaches. There is an approach where the requirements for indicators / indicators come down from above. For example, so many and so many products must be sold, and then the expected sales in different branches are distributed according to the possibilities. And often this is not taken from the ceiling (although I would not take it as a rule :). This approach is a little complicated and in principle it depends on the approach described below, but as a construct it has the right to exist separately.
Very often indicators are collected from below, i.e. from the lower level. And as in your case - from the logs.
Imagine that each of your affiliates sells different products. Those. for each product and the day it was sold - you can report. Now imagine doing this not only by day, but also, for example, by weekly sales figures. But for branches. Imagine the headquarters of this firm with various branches. And from each of them flows information on sales. For example monthly information. Those. in the central office, no one will ever be able to say how much was sold in all branches yesterday, the day before yesterday, etc. Because the level of aggregation is very rough. It's the same as repairing a clock with an axe. And if the task arises, to do more accurate statistics in the center, then the level of data submission will not be monthly, but everyday. Seems to be good. But due to the fact that information goes every day, the amount of data increases,
Plus the summation costs for all branches in one place, which for some time can make either your excel or your database in the center unavailable for some time, which increases the risk that not all everyday data will be read and processed at all. sort of a vicious circle of problems.
Those. sometimes they make a compromise. And they stipulate where and at what level their own statistics are made, which are then collected from all branches and what statistics are made there.
And the lower the level where data on sales, usage, etc. is created. , the more data needs to be processed. But only their own. And then in a compressed form they are transmitted further along the chain. But still, for example, for each product. There, in turn, information about a specific product is artificially replaced, for example, with a product class. To do this, where is written which class each product belongs to. Those. the general statistics for 10,000 products is replaced by 10 classes, and it is these statistics that are used in the echelons above.
Branch calculation:
1000 products are sold every day. Those. 1000 records are sent to the center every day. A lot or a little - everything is figurative. If these products are replaced by classes, then eg 10 digits from each branch will be sent every day. Which is much less, but then no one in the center will know that Petya Vasechkin was the best seller today. Because they don't have that information. And for global decisions, this information is not needed.
To your question, what should be used, I will answer this way. Sit down and try to imagine yourself in the place where you want to see these numbers in order to make a decision. Those. for the branch manager should be enough - seller, date (day/week/month/quarter/year), product, number of sales status, if return. For the center - branch, date (day/week/month/quarter/year), product, quantity. For the president of the republic - date (day/week/month/quarter/year), product class quantity. Etc.
And to be honest - in your question there is not enough specific information. So the answers will be the same. Think and share with them. And who knows, maybe they can help you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question