How to tell PostgreSQL about a relationship

From: Thomas <iamkenzo(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to tell PostgreSQL about a relationship
Date: 2008-10-26 09:44:29
Message-ID: 55da14450810260244nb03c79drb5bf64274fb02c97@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have jumped from MySQL to PostgreSQL, and I wanted to know how we
declare that a table depends on another one.

Currently I have 3 tables:

Product(id, title, price)
Item(id, product_id, order_id, quantity)
Order(id, amount, paid)

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?

Best regards,

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2008-10-26 12:44:41 Re: How to tell PostgreSQL about a relationship
Previous Message Thomas 2008-10-26 09:10:47 Re: a LEFT JOIN problem