Re: Foreign Key inter databases - Mailing list pgsql-sql

From Dani Castaños
Subject Re: Foreign Key inter databases
Date
Msg-id 46B2D823.7020700@gmail.com
Whole thread Raw
In response to Re: Foreign Key inter databases  ("Josh Tolley" <eggyknap@gmail.com>)
Responses Re: Foreign Key inter databases  (Erik Jones <erik@myemma.com>)
List pgsql-sql
Josh Tolley escribió:
> On 8/2/07, Dani Castaños <danitao.mailists@gmail.com> wrote:
>   
>> Hi all!
>>
>> Is it possible to have a foreign key where referenced table is in
>> another database?
>>
>> Thank you in advance
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 1: if posting/reading through Usenet, please send an appropriate
>>        subscribe-nomail command to majordomo@postgresql.org so that your
>>        message can get through to the mailing list cleanly
>>
>>     
>
> Unless you use things like dblink to make two separate databases think
> they're one database, you really can't do anything where one database
> depends on another. Your best bet, if you can have both data sets on
> the same machine, is to stick them in two separate schemas, and then
> you can have foreign keys on a table in one schema referencing a table
> in another schema. That's (in part) what schemas are for in the first
> place -- to separate logically distinct data sets while allowing
> accesses between the two when necessary.
>
> If for whatever reason having all the data on one machine isn't
> possible, you can try using dbi-link or dblink to create links between
> the two databases and do foreign keys that way, but I've never used
> either, so that might not work/make sense/be possible, etc.
>
> -Josh
>   

Thanks Josh!
I use dblinks for queries, but I'm pretty sure you can't use it in 
constraints definitions.
My situation is that I have one main database and many customer's 
databases. In main database there is a languages table, and customers 
databases must use the language_id. Then, I don't want to create 
languages table in each customer db, that's the reason why i was trying 
to do a foreign key from customer db to main db.


pgsql-sql by date:

Previous
From: "Christian Kindler"
Date:
Subject: Re: Count of rows
Next
From: Steve Midgley
Date:
Subject: Increment a sequence by more than one