Received: from yara.imsd.uni-mainz.de (yara.IMSD.Uni-Mainz.DE [134.93.144.68]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f637ata02673 for ; Tue, 3 Jul 2001 03:36:55 -0400 (EDT) (envelope-from wagner@imsd.uni-mainz.de) Received: (from smap@localhost) by yara.imsd.uni-mainz.de (8.9.3/8.9.3/lxs_5.2) id JAA28107 for ; Tue, 3 Jul 2001 09:36:23 +0200 Received: from hermes.imsd.uni-mainz.de(134.93.64.80) by yara.imsd.uni-mainz.de via smap (V2.1/2.1+anti-relay+anti-spam) id xma028101; Tue, 3 Jul 01 09:35:58 +0200 Received: from imsd.uni-mainz.de (unverified [134.93.64.34]) by hermes.imsd.uni-mainz.de (EMWAC SMTPRS 0.83) with SMTP id ; Tue, 03 Jul 2001 09:35:35 +0200 Message-ID: <3B416A35.E5E2AC62@imsd.uni-mainz.de> Date: Tue, 03 Jul 2001 08:46:13 +0200 From: Markus Wagner Organization: IMSD X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.13 i686) X-Accept-Language: en MIME-Version: 1.0 To: "pgsql-sql@postgresql.org" Subject: traversing foreign key relationships between tables Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200107/12 X-Sequence-Number: 3793 Hi, I have the following problem. There is a trigger event on a table T. Table t is linked through n intermediate tables (mostly n = 0) to a primary master Table M. What I need to do is find the entry in M which corresponds to the triggered entry in T. I think in pseudocode it would be like this: S = set of foreign keys in my entry in T while S is not empty { get s from S find referenced table t for s if t = M then return s as primary key into M put all foreign keys in t into S } My problem is: How to identify the attributes in a table (in pg_attribute) which are foreign keys into other tables and how to get the relids of these other tables? Thank you very much, Markus