From: | சிவகுமார் மா <masivakumar(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Enforcing Join condition |
Date: | 2007-11-15 07:54:04 |
Message-ID: | 139e14f00711142354u2412695blb1f9b8ecfef30182@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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 tables)
INSERT INTO test (info_type, info_reference) values ('abc','111'); ---
111 from tableA
INSERT INTO test (info_type, info_reference) values ('def','101');
--- 101 from tableB
INSERT INTO test (info_type, info_reference) values ('abc','119'); ---
119 from tableA
INSERT INTO test (info_type, info_reference) values ('def','103');
--- 103 from tableB
INSERT INTO test (info_type, info_reference) values ('def','104');
--- 104 from tableB
INSERT INTO test (info_type, info_reference) values ('def','105');
--- 105 from tableB
INSERT INTO test (info_type, info_reference) values ('def','111');
--- 111 from tableB
Now when joining tableA or tableB with test, joining only
info_reference will be wrong, we should also mention the info_type
value.
1. Is this an appropriate design for this requirement?
2. Is there a way to enforce the dual condition checking on all
queries. If a join is made to info_reference, info_type should also be
specified?
Thanks.
Ma Sivakumar
--
மா சிவகுமார்
எல்லோரும் எல்லாமும் பெற வேண்டும்
http://masivakumar.blogspot.com
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory Stark | 2007-11-15 08:38:13 | Re: Variable LIMIT and OFFSET in SELECTs |
Previous Message | Tom Lane | 2007-11-15 05:41:08 | Re: Variable LIMIT and OFFSET in SELECTs |