Search Postgresql Archives

Enforcing Join condition

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

 



Is there a way to force join conditions in queries i.e. When a join ismade to a table on a particular field, another column should also bechecked?
CREATE TABLE test (info_type varchar(3), info_reference integer);(depending on info_type, info_reference will contain key values fromdifferent tables)
INSERT INTO test (info_type, info_reference) values ('abc','111'); ---111 from tableAINSERT INTO test (info_type, info_reference) values ('def','101');--- 101 from tableBINSERT INTO test (info_type, info_reference) values ('abc','119'); ---119 from tableAINSERT INTO test (info_type, info_reference) values ('def','103');--- 103 from tableBINSERT INTO test (info_type, info_reference) values ('def','104');--- 104 from tableBINSERT INTO test (info_type, info_reference) values ('def','105');--- 105 from tableBINSERT INTO test (info_type, info_reference) values ('def','111');--- 111 from tableB
Now when joining tableA or tableB with test, joining onlyinfo_reference will be wrong, we should also mention the info_typevalue.
1. Is this an appropriate design for this requirement?2. Is there a way to enforce the dual condition checking on allqueries. If a join is made to info_reference, info_type should also bespecified?
Thanks.
Ma Sivakumar-- மா சிவகுமார்எல்லோரும் எல்லாமும் பெற வேண்டும்http://masivakumar.blogspot.com
---------------------------(end of broadcast)---------------------------TIP 9: In versions below 8.0, the planner will ignore your desire to       choose an index scan if your joining column's datatypes do not       match

[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