Re: two tables - foreign keys referring to each other...

From: Chris Czeyka <czeyka(at)skwea(dot)co(dot)jp>
To: "Kirby C(dot) Bohling" <kbohling(at)birddog(dot)com>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: two tables - foreign keys referring to each other...
Date: 2001-02-21 05:09:49
Message-ID: 3A934D9D.1019C0EA@skwea.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

ThX Kirby, ThX Martijn,

as you can see I'm new to the SQL- and database world.
My policy for this project is to FORCE an admin to be in an institute. If one
admin behaves bad for the database project the institute is responsible for
her/him. This institute would be represented by a special admin (therefore the
link back).

Anyway, I see that crosslinking is really a little bit tricky...
I will do this check in the application level (Java) and see, if this is easier
and even necessary. For now I might use only admin(fk)->institute. This is
necessary to trace back responsibility.

as beginner I appreciate good hints,

cheers,
Chris

>
> IMHO, you should consider not having the admin table have a link to the
> institute table. If you want to find the institute a particular admin
> is connected with, find that look in the institutes table. The astute
> reader will note the advice is symmetric, you can not have a link from
> the institute to the admin. If you don't want to have dangling admin's
> you might be able to get a trigger/stored procedure to do it for you
> (Note:I done triggers in Oracle, never in PostGres so take that with a
> grain of salt. I would be shocked if you couldn't do it with a Trigger
> under PostGres. I believe it us commonly done with long objects as a
> matter of fact).
>
> Do what you like, and I hope this helps.
>
> Kirby
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tod McQuillin 2001-02-21 05:34:31 Re: Bug in my ( newbie ) mind?
Previous Message Christopher Sawtell 2001-02-21 05:00:13 Bug in my ( newbie ) mind?

Browse pgsql-sql by date

  From Date Subject
Next Message Ken Kline 2001-02-21 05:14:02 logging a script
Previous Message Martijn van Oosterhout 2001-02-21 04:00:54 Re: two tables - foreign keys referring to each other...