I am creating an application and I will need statistics from the data I will have in my SQL database.
For example, I have a table "animals", with a column "type" that can be equal to "dog" or "cat". I need to calculate statistics of the type "number of animals", which will therefore be equal to the number of entities in my table "animals", or "percentage of cat", which will therefore be equal to the number of cat/ number of animals * 100.
This example was simplified to the maximum, but in my application, it will be more complex calculations, and in greater numbers.
For my statistics, do I have to create another "statistics" table, and update it every time I modify my "animals" table, or do I calculate these statistics every time I have a request on my API? What are the best practices?
Aucun commentaire:
Enregistrer un commentaire