Raw data or pre-calculated values ​​in the database?

As a rule, it is better to store raw data with pre-calculated values ​​in the database and focus on keeping the database up to date if I delete or delete a row when using pre-calculated values ​​to display to the user

OR

is it better to store raw data and calculate the correct displayed values ​​on the fly?


An example (relevant to my project) will look like the following:

You have a timer application. In my case, it uses Core Data. It is not connected to the Internet, but a stand-alone application running on a computer or mobile device (user choice). The application stores raw start time and raw end time. The application should display the duration of the event and the interval in which events occur. Would it be better to save the pre-calculated “duration” time and even a formatted time line that will be used for output, or would it be better to calculate the duration “on the fly”, so to speak, for display?

The same thing happens with an interval, although there is a different level, because when I create / delete / update a row in the database, I will have an interval update for the elements it affects. Or is it better to just figure out how the application is executing?

For the record, I'm not trying to micro-optimize. I am trying to find the best way to reduce the amount of code that I have to support. If productivity improves as a result, so be it.

Thoughts?

+3
source share
3 answers

, ( /), , ( , ). , , , .

, , , .

, , , -proc. , .

, , .

+4

, , - . .

, -, , , , , , , , .

.

, " ". , . , , . :)

+3

, ( ) . , , .

iPhone 4 , NSString UITableViewCell 1000 , , .

, . , , ( , ).

, , . / , , (.. , ).

0
source

Source: https://habr.com/ru/post/1769599/


All Articles