Re: deletion and many-to-one

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Jennifer Vargas <w47fnpch02(at)sneakemail(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: deletion and many-to-one
Date: 2003-08-09 22:11:44
Message-ID: 20030809151019.A18519-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sat, 9 Aug 2003, Jennifer Vargas wrote:

> If you have a many-to-one relationship, such as a contact list where
> several people
> share an address, you may want to delete the child record once the last
> reference to
> it is gone. I don't see how to implement a reference-counting scheme in
> a database.
> What's the right way to accomplish this?

Probably a trigger on update or delete of the referencing table. If
you're not worried about some of the multi-session concurrency problems,
it's a marginally simple plpgsql trigger.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Ron Johnson 2003-08-09 23:01:04 Re: Auto_Increment
Previous Message Jennifer Vargas 2003-08-09 21:17:15 deletion and many-to-one