It is very usual in many applications, that the application has to manipulate information obtained as a result of the processing of other basic information, making some different operations from this basic information.
When this happens, a decision can be made of storing only the basic information. From this basic information, all other needed information can be deducted, as a result of the manipulation and processing of the basic information. If this is the decision, then each time that we need to have information as a result of the processing of other, the program must perform the calculation of this processed information based on the basic information. In occasions, having to calculate each time the processing of information to obtain other, can have a high computational cost, and it can be worth to calculate it only once and updating it successively, and keeping it stored in other portion of memory, devoted for this processed information.
Another possible decision is to store not only the basic information (from which all the rest of information can be deducted) but also to store the processed information that is going to be used many times in the application and allocate memory for it. In this way, the memory used will be increased, but the execution time devoted to the calculation of the processed information can be reduced.
Making a comparison between both solutions, there is a trade off for the selection, and the decision of using one or another must be done taken into account different factors such as: which are the limitations of our application (in memory, execution time, etc.), how many extra memory implies to have the extra information processed, how much calculation time implies to have to process the information each time instead of processing it once and updating it each time that there is one change (depending on the application such updating can be more or less time consuming, as well as the processing operation can cost more or less).
In the case of our reference application, an example of information that can be obtained as a result of the processing of other, is the number of photos that a specific author has taken. Such information can be extracted from the photo and author tables, traversing all the photo instances and looking for the ones which author identifier matches with the desired authors, in which case 1 is added. Therefore, we can make the decision of processing the basic information for obtaining the number of photos of an specific author, or calculating it only once at the beginning, store it in an extra memory area, and implement a programming code that increases 1 the number of photos of this author every time that this author includes a photo. This extra memory area might be an extension of the authors table for including this field of the number of photos. Although this information is redundant (it can be obtained from the processing of other information), it can result of benefit depending on the application functionality to have this replicated information.
Answer the following questions