Re: How to tell PostgreSQL about a relationship - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject Re: How to tell PostgreSQL about a relationship
Date
Msg-id 20081026124441.GA6645@depesz.com
Whole thread Raw
In response to How to tell PostgreSQL about a relationship  (Thomas <iamkenzo@gmail.com>)
List pgsql-general
On Sun, Oct 26, 2008 at 10:44:29AM +0100, Thomas wrote:
> In pgAdmin I have removed a few order entries, but the items
> associated to them are still here, now I have zombie items floating
> around that don't belong to any order. So how do I tell PgSQL that
> when I remove a given order, it should remove all associated items
> also?

use foreign keys.

syntax to add them:
1. "references table (field)" in create table/
2. alter table add foreign key

Best regards,

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

pgsql-general by date:

Previous
From: Thomas
Date:
Subject: How to tell PostgreSQL about a relationship
Next
From: Thomas
Date:
Subject: Re: a LEFT JOIN problem