Re: Feature Proposal: Constant Values in Columns or Foreign Keys

From: Nils Gösche <cartan(at)cartan(dot)de>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Feature Proposal: Constant Values in Columns or Foreign Keys
Date: 2012-04-18 18:37:31
Message-ID: 002801cd1d92$5072e470$f158ad50$@de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bartosz Dmytrak wrote:

> according to DB theory:
> 1NF: Table faithfully represents a relation and has no repeating groups
> 2NF: No non-prime attribute in the table is functionally dependent on a proper subset of anycandidate key.
> source: http://en.wikipedia.org/wiki/Database_normalization#Normal_forms

> so these constants are not in line with this approach.

This is true. That's why you would have to guard the "constantness" of the column/attribute with a CHECK constraint, to avoid update anomalies.

Yes, the whole model would be simpler and more beautiful without the type column, and trigger functions on the derived tables instead. On the other hand, the foreign key including the type field might be faster than the foreign key without the type field plus trigger function. So, if this approach is any good, then only if it is actually faster. No, I haven't timed it :-)

Regards,
--
Nils Gösche
Don't ask for whom the <Ctrl-G> tolls.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Welty, Richard 2012-04-18 18:41:23 somewhat high profile project using PostgreSQL
Previous Message Efraín Déctor 2012-04-18 18:32:52 pgstat wait timeout