Managing Computed Attributes

Learn how storing derived fields in databases poses integrity and redundancy challenges.

Challenges of storing derived fields

Derived fieldsDerived fields are attributes whose values are calculated from other fields in the database using some formula., such as SalesAmount, are generally not stored in the database because they can always be computed from the base information. Storing such fields in a database can lead to several issues such as data integrity, redundancy, and more.

Data integrity

There’s a risk of inconsistencies if the base data changes, but the derived fields aren’t updated accordingly. This can lead to inaccurate information.

To identify potential inconsistencies, let’s write a query to examine values where the derived amount (SalesAmount) does not match the actual amount.

Get hands-on with 1400+ tech skills courses.