pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Tolley <eggyknap@gmail.com>
To: Dani CastaƱos <danitao.mailists@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Foreign Key inter databases
Date: Thu, 2 Aug 2007 13:23:36 -0600
Message-ID: <e7e0a2570708021223n1e6e234dtbd6f04f6e9089189@mail.gmail.com> (raw)
In-Reply-To: <46B203BD.1000102@gmail.com>
References: <46B203BD.1000102@gmail.com>

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



view thread (4+ messages)  latest in thread

Message-ID: <e7e0a2570708021223n1e6e234dtbd6f04f6e9089189@mail.gmail.com>
Permalink:  ../e7e0a2570708021223n1e6e234dtbd6f04f6e9089189@mail.gmail.com/
Also on:    postgresql.org/message-id/e7e0a2570708021223n1e6e234dtbd6f04f6e9089189@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: eggyknap@gmail.com, danitao.mailists@gmail.com
  Subject: Re: Foreign Key inter databases
  In-Reply-To: <e7e0a2570708021223n1e6e234dtbd6f04f6e9089189@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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