Re: Enforcing Join condition - Mailing list pgsql-general

From Sam Mason
Subject Re: Enforcing Join condition
Date
Msg-id 20071115144721.GD1955@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to Re: Enforcing Join condition  ("சிவகுமார் மா"<masivakumar@gmail.com>)
Responses Re: Enforcing Join condition  ("சிவகுமார் மா"<masivakumar@gmail.com>)
List pgsql-general
On Thu, Nov 15, 2007 at 07:46:46PM +0530, ??????????????????????????? ?????? wrote:
> On Nov 15, 2007 5:52 PM, Sam Mason <sam@samason.me.uk> wrote:
> > What I tend to do here, is something like:
> >
> >   CREATE TABLE test (
> >     type  INTEGER,
> >     ref1 INTEGER REFERENCES table1 CHECK ((type = 1) = (ref1 IS NOT NULL)),
> >     ref2 INTEGER REFERENCES table2 CHECK ((type = 2) = (ref2 IS NOT NULL)),
> >     ref3 INTEGER REFERENCES table3 CHECK ((type = 3) = (ref3 IS NOT NULL))
> >   );
>
> Thanks for sharing. Will try it. But, we have more than 10 types in
> one table. Will be tough to handle.

As Albe suggested, a view is about all that's going to help the poor
people who work with this.  When I do this sort of thing, I tend to
find that there are very few queries that actually need everything all
together in one place.  It's generally that (using the naming above)
that you'd do a query on "table1", "test" and something that references
"test".  Queries that reference "test", "table1" and "table2" are
reasonably rare.  Of course, it could be that I was just lucky here.


  Sam

pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Chunk Delete
Next
From: Sam Mason
Date:
Subject: Re: Chunk Delete