pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedForeign key from another database
4+ messages / 4 participants
[nested] [flat]
* Foreign key from another database
@ 2003-04-03 09:16 Antti Ijäs <antti.ijas@arcada.fi>
0 siblings, 3 replies; 4+ messages in thread
From: antti.ijas@arcada.fi @ 2003-04-03 09:16 UTC (permalink / raw)
To: pgsql-sql
Hi,
Can I have a reference (with cascading), to another database? Let me
try to explain the situation a little better ;-)
I have a "main" database, clients. Then I have another database. Let's
call that program1. In program1 I have a table pTable and in clients I
have a table namned Client. Like this:
\c clients
CREATE TABLE Client (
CustId Serial PRIMARY KEY,
....
);
\c program1
CREATE TABLE pTable (
pId SERIAL PRIMARY KEY,
CustId INTEGER,
....
);
I would like the data to be dropped in pTable automatically, when the
client is deleted....
/ Antti
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Foreign key from another database
@ 2003-04-03 18:01 Joe Conway <mail@joeconway.com>
parent: Antti Ijäs <antti.ijas@arcada.fi>
2 siblings, 0 replies; 4+ messages in thread
From: Joe Conway @ 2003-04-03 18:01 UTC (permalink / raw)
To: Antti Ijäs <antti.ijas@arcada.fi>; +Cc: pgsql-sql
Antti Ijäs wrote:
> Can I have a reference (with cascading), to another database? Let me
> try to explain the situation a little better ;-)
>
You can write a trigger that uses functions from contrib/dblink to
execute a command in another database. However, without two-phase commit
support I don't think you can be sure the entire operation is atomic.
Joe
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Foreign key from another database
@ 2003-04-03 18:42 Rod Taylor <rbt@rbt.ca>
parent: Antti Ijäs <antti.ijas@arcada.fi>
2 siblings, 0 replies; 4+ messages in thread
From: Rod Taylor @ 2003-04-03 18:42 UTC (permalink / raw)
To: Antti Ijäs <antti.ijas@arcada.fi>; +Cc: pgsql-sql
You might want to look into using multiple schemas in a single database
rather than multiple databases.
If you switch to the above, then you can do what you're looking for.
Postgresql has limited cross database abilities (contrib/dblink), but
not cross database foreign keys.
On Thu, 2003-04-03 at 04:16, Antti Ijäs wrote:
> Hi,
>
> Can I have a reference (with cascading), to another database? Let me
> try to explain the situation a little better ;-)
>
> I have a "main" database, clients. Then I have another database. Let's
> call that program1. In program1 I have a table pTable and in clients I
> have a table namned Client. Like this:
>
> \c clients
> CREATE TABLE Client (
> CustId Serial PRIMARY KEY,
> ....
> );
>
> \c program1
> CREATE TABLE pTable (
> pId SERIAL PRIMARY KEY,
> CustId INTEGER,
> ....
> );
>
> I would like the data to be dropped in pTable automatically, when the
> client is deleted....
>
> / Antti
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
Rod Taylor <rbt@rbt.ca>
PGP Key: http://www.rbt.ca/rbtpub.asc
Attachments:
signature.asc (application/pgp-signature, 186B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Foreign key from another database
@ 2003-04-03 22:09 CoL <col@mportal.hu>
parent: Antti Ijäs <antti.ijas@arcada.fi>
2 siblings, 0 replies; 4+ messages in thread
From: CoL @ 2003-04-03 22:09 UTC (permalink / raw)
To: pgsql-sql
Use trigger on Client after delete, and dblink from contrib.
C.
Antti Ijäs wrote, On 4/3/2003 11:16 AM:
> Hi,
>
> Can I have a reference (with cascading), to another database? Let me
> try to explain the situation a little better ;-)
>
> I have a "main" database, clients. Then I have another database. Let's
> call that program1. In program1 I have a table pTable and in clients I
> have a table namned Client. Like this:
>
> \c clients
> CREATE TABLE Client (
> CustId Serial PRIMARY KEY,
> .....
> );
>
> \c program1
> CREATE TABLE pTable (
> pId SERIAL PRIMARY KEY,
> CustId INTEGER,
> .....
> );
>
> I would like the data to be dropped in pTable automatically, when the
> client is deleted....
>
> / Antti
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-04-03 22:09 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-03 09:16 Foreign key from another database Antti Ijäs <antti.ijas@arcada.fi>
2003-04-03 18:01 ` Joe Conway <mail@joeconway.com>
2003-04-03 18:42 ` Rod Taylor <rbt@rbt.ca>
2003-04-03 22:09 ` CoL <col@mportal.hu>
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