Search Postgresql Archives

Re: Enforcing Join condition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 15, 2007 at 07:46:46PM +0530, ??????????????????????????? ?????? wrote:
> On Nov 15, 2007 5:52 PM, Sam Mason <sam@xxxxxxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux