Re: [GENERAL] Enforcing Join condition

2007-11-15 Thread Albe Laurenz
சிவகுமார் மா wrote: > CREATE TABLE test (info_type varchar(3), info_reference integer); > (depending on info_type, info_reference will contain key values from > different tables) > > INSERT INTO test (info_type, info_reference) values ('abc','111'); --- > 111 from tableA > INSERT INTO test (info_t

Re: [GENERAL] Enforcing Join condition

2007-11-15 Thread Sam Mason
On Thu, Nov 15, 2007 at 07:46:46PM +0530, ??? ?? wrote: > On Nov 15, 2007 5:52 PM, Sam Mason <[EMAIL PROTECTED]> wrote: > > What I tend to do here, is something like: > > > > CREATE TABLE test ( > > type INTEGER, > > ref1 INTEGER REFERENCES table1 CHECK ((typ

Re: [GENERAL] Enforcing Join condition

2007-11-15 Thread Albe Laurenz
சிவகுமார் மா wrote: >> You want to have a "conditional" foreign key reference that checks >> against different tables depending on a "type" field, right? >> >> For complicated conditions like this, you could use a >> BEFORE INSERT trigger that throws an error when the condition >> is violated. > >

Re: [GENERAL] Enforcing Join condition

2007-11-15 Thread சிவகுமார் மா
On Nov 15, 2007 5:52 PM, Sam Mason <[EMAIL PROTECTED]> 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 N

Re: [GENERAL] Enforcing Join condition

2007-11-15 Thread சிவகுமார் மா
On Nov 15, 2007 7:32 PM, Albe Laurenz <[EMAIL PROTECTED]> wrote: > > You want to have a "conditional" foreign key reference that checks > against different tables depending on a "type" field, right? > > For complicated conditions like this, you could use a > BEFORE INSERT trigger that throws an err

Re: [GENERAL] Enforcing Join condition

2007-11-15 Thread Sam Mason
On Thu, Nov 15, 2007 at 01:24:04PM +0530, ??? ?? wrote: > Is there a way to force join conditions in queries i.e. When a join is > made to a table on a particular field, another column should also be > checked? > > CREATE TABLE test (info_type varchar(3), info_referenc

Re: [GENERAL] Enforcing Join condition

2007-11-15 Thread சிவகுமார் மா
On Nov 15, 2007 8:17 PM, Sam Mason <[EMAIL PROTECTED]> wrote: > 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

[GENERAL] Enforcing Join condition

2007-11-14 Thread சிவகுமார் மா
Is there a way to force join conditions in queries i.e. When a join is made to a table on a particular field, another column should also be checked? CREATE TABLE test (info_type varchar(3), info_reference integer); (depending on info_type, info_reference will contain key values from different tabl