Re: foreign key constraint across databases

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Siva Kumar <siva(at)leatherlink(dot)net>
Cc: pgsql-general(at)postgresql(dot)org, Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Subject: Re: foreign key constraint across databases
Date: 2003-03-07 04:38:25
Message-ID: 27637.1047011905@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Siva Kumar <siva(at)leatherlink(dot)net> writes:
> Is it possible to have a column in Table-2 of Database-B to have a
> foreign key constraint referencing Table-1 of Database-A?
>>
>> What are you planning to use it for (ie, why separate databases rather
>> than something like separate schemas)

> Our application is used by different companies for their operation and will be
> accessible over internet. We want to have separate databases for each company
> and the application will interact with all the databases to enable
> buyer-supplier relationships etc.

Let me get this straight: you want separable, removable databases for
each client --- but you are going to maintain foreign-key relationships
between them? Something needs rethinking here.

Either you need an airtight separation between clients, or you don't.
If you don't, then a schema per client ought to do the job. If you do,
I think foreign-key relationships are mighty questionable. Exactly
which client is going to have their queries fail when the FK constraint
is violated? And how are you going to explain the failure to the client
that thought they had an airtight private database?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2003-03-07 05:29:22 Re: Why PostgreSQL?
Previous Message Bruce Momjian 2003-03-07 03:58:00 Re: Is renaming a database easy or dangerous