pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Wagner <wagner@imsd.uni-mainz.de>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: traversing foreign key relationships between tables
Date: Tue, 03 Jul 2001 08:46:13 +0200
Message-ID: <3B416A35.E5E2AC62@imsd.uni-mainz.de> (raw)

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



Message-ID: <3B416A35.E5E2AC62@imsd.uni-mainz.de>
Permalink:  ../3B416A35.E5E2AC62@imsd.uni-mainz.de/
Also on:    postgresql.org/message-id/3B416A35.E5E2AC62@imsd.uni-mainz.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: wagner@imsd.uni-mainz.de
  Subject: Re: traversing foreign key relationships between tables
  In-Reply-To: <3B416A35.E5E2AC62@imsd.uni-mainz.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox