Bruce Pullen <br**********@hotmail.com> wrote:
Thanks to denormalised developers, I have a table where only one
column of three can ever be populated per row. I feel
a) BEFORE INSERT/UPDATE triggers would have an unacceptable
performance impact (this table will be accessed heavily).
b) creating three views would be clumsy.
c) restricting inserts/updates using the application is far too much
to ask.
What's the behavior that you want to have if 2 (or 3) of these columns are
to be populated? If you want to return an error, then a simple check
constraint on the table could be sufficient:
CHECK ( col1 IS NOT NULL AND col2 IS NULL AND col3 IS NULL OR
col1 IS NULL AND col2 IS NOT NULL AND col3 IS NULL OR
col1 IS NULL AND col2 IS NULL AND col3 IS NOT NULL )
If you want to handle the situation in the database system, then you would
need some more logic and triggers could be the way to go.
--
Knut Stolze
Information Integration
IBM Germany / University of Jena