Re: How to tell PostgreSQL about a relationship

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Thomas <iamkenzo(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to tell PostgreSQL about a relationship
Date: 2008-10-26 12:44:41
Message-ID: 20081026124441.GA6645@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)depesz(dot)com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Niklas Johansson 2008-10-26 12:57:04 Re: How to tell PostgreSQL about a relationship
Previous Message Thomas 2008-10-26 09:44:29 How to tell PostgreSQL about a relationship