pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedForeign key
3+ messages / 3 participants
[nested] [flat]
* Foreign key
@ 2000-10-03 14:52 Paulo Roberto Siqueira <paulo.siqueira@usa.net>
0 siblings, 1 reply; 3+ messages in thread
From: Paulo Roberto Siqueira @ 2000-10-03 14:52 UTC (permalink / raw)
To: PGSQL Novice <pgsql-novice@postgresql.org>; pgsql-admin
This list have helped me a lot. That's why I'm here again asking for more
information.
I've read all the documentation, but I need more information on how
postgres implements foreign key on version 7.0.2. I know it uses triggers.
More information is needed though. I want to know the mechanism, when it
will change to real foreign key etc.
Thank you all,
Paulo Siqueira
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Foreign key
@ 2000-10-03 17:16 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Paulo Roberto Siqueira <paulo.siqueira@usa.net>
0 siblings, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2000-10-03 17:16 UTC (permalink / raw)
To: Paulo Roberto Siqueira <paulo.siqueira@usa.net>; +Cc: PGSQL Novice <pgsql-novice@postgresql.org>; pgsql-admin
On Tue, 3 Oct 2000, Paulo Roberto Siqueira wrote:
> This list have helped me a lot. That's why I'm here again asking for more
> information.
> I've read all the documentation, but I need more information on how
> postgres implements foreign key on version 7.0.2. I know it uses triggers.
> More information is needed though. I want to know the mechanism, when it
> will change to real foreign key etc.
The mechanics are that a foreign key constraint definition is turned into
three constraint triggers (more on this in a second), one on the foreign
key table, two on the primary key table. The one on the foreign key table
is an after update/insert trigger that checks that the row matches. The
two on the primary key table are after delete and update (respectively)
and either implement a check to make sure the row isn't referenced (no
action/restrict) or implement the referential action (on delete ...
on cascade ...) The checks and actions are all implemented in C using
SPI by building appropriate queries.
Constraint triggers are a little different from normal triggers because
there is some additional stuff to handle the relationship between the
tables and a deferred trigger queue to handle deferrable constraints.
I'm not sure what you mean by real foreign key above, so I'm not sure
how to answer the last bit.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Foreign Key
@ 2002-10-02 15:44 Tim Jones <tij@ucs.co.za>
0 siblings, 0 replies; 3+ messages in thread
From: Tim Jones @ 2002-10-02 15:44 UTC (permalink / raw)
To: pgsql-admin
I want to query the dictionary to pull foreign key relationships in the
format parent_table.column,child_table.column.
I can see this info in pg_trigger but it is not very accessible. Any ideas?
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-10-02 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-03 14:52 Foreign key Paulo Roberto Siqueira <paulo.siqueira@usa.net>
2000-10-03 17:16 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-10-02 15:44 Foreign Key Tim Jones <tij@ucs.co.za>
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