Data Logic - Do you use de-normalized database fields for calculated values?

Last updated by Jeoffrey Fischer [SSW] 6 months ago.See history

Most reports contain some sort of calculation - order totals, freight costs and so on. You have 3 options on how to display this in your report:

  1. Use an expression in the report (bad). Avoid doing this because your logic is scattered throughout the report, and also because this logic cannot be shared around reports or with your other web and windows applications.
  2. Call an assembly with the calculated logic (better). This is better than using a calculation expression because the logic can be shared over multiple reports, and it is easy to find as all the logic is inside the one .NET project. It is not the best solution because there is an extra level of complexity as you have to build, compile and reference the assembly containing the logic.
  3. Use a denormalised database field (best). This is the best way because not only is the calculated value accessible directly from the report's data set, but the value is already pre-calculated which can provide a performance improvement (compared to calculating the value each time the report runs).

Figure: Bad example - Avoid using expressions for calculated values

Figure: Bad example - Avoid using external assemblies for calculated values - it adds an unnecessary level of complexity

Figure: Good example - Use a denormalised database field for calculated values

We open source.Loving SSW Rules? Star us on GitHub. Star
Stand by... we're migrating this site to TinaCMS