Re: foreign key constraint across databases - Mailing list pgsql-general

From Tom Lane
Subject Re: foreign key constraint across databases
Date
Msg-id 27637.1047011905@sss.pgh.pa.us
Whole thread Raw
In response to Re: foreign key constraint across databases  (Siva Kumar <siva@leatherlink.net>)
List pgsql-general
Siva Kumar <siva@leatherlink.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

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Is renaming a database easy or dangerous
Next
From: Bruce Momjian
Date:
Subject: Re: Why PostgreSQL?