Re: referential integrity and defaults, DB design or trick

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: referential integrity and defaults, DB design or trick
Date: 2007-12-20 21:37:22
Message-ID: 20071220223722.7ca89c91@webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 20 Dec 2007 17:53:23 +0000
Richard Huxton <dev(at)archonet(dot)com> wrote:

> CREATE TABLE properties (
> pid serial,
> name text,
> PRIMARY KEY (pid)
> );
> CREATE TABLE user_default_property (
> uid int NOT NULL REFERENCES users,
> pid int NOT NULL REFERENCES properties,
> PRIMARY KEY (uid)
> );
> CREATE TABLE user_property_choices (
> uid int NOT NULL REFERENCES users,
> pid int NOT NULL REFERENCES properties
> PRIMARY KEY (uid)
> );

> That allows you to have 0 or 1 defaults per user and 0 or 1 choices
> per user too.

Thanks, this led me to insist on an idea I abandoned mislead by bad
data quality, looking at written code, no matter how simple it is is
better than insisting in speculating in your mind hoping you'll avoid
refactoring.

The default property (that is actually made by several fields) in my
case is not completely homogeneous with the others, because it has a
double meaning.
It is cleaner to split the meanings and the data. This will even give
me a chance to avoid completely the concept of default property.

thanks, I think you put me on the right path.

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2007-12-20 22:12:44 Re:
Previous Message Dave Page 2007-12-20 21:29:09 Re: Deploy postgres - upgrade strategy