Edwin de Koning
Edwin de Koning

Reputation: 14387

What are the trade-offs when denormalizing for a computed column?

I hope I am not asking a too obvious question here.

For my current project I am designing a relatively simple database using sql server 2008. For one of the tables I have decided to introduce a 'Computed Column' (not persisted). Its expression is simply the product of 2 other numeric columns and its sole reason for existence is convenience (I am doing some one-way databinding to a webpage).

I realized however that using a computed column violates the first normal form. This got me wondering: Wat are the trade-offs? If my only reason for the computed column is convenience, does it outweigh the denormalization?

Upvotes: 2

Views: 368

Answers (2)

TomTom
TomTom

Reputation: 62101

Its expression is simply the product of 2 other numeric columns and its sole reason for existence is convenience (I am doing some one-way databinding to a webpage).

Then put the calculation in your SELECT statement, not into the database.

Upvotes: 0

iDevlop
iDevlop

Reputation: 25262

"using a computed column violates the first normal form": not at all ! It's not stored, it is re-calculated with the latest data at all time. So it is an excellent solution, just like having a calculated column in a view.

Upvotes: 1

Related Questions