When to use cascading deletes?

From: David <wizzardx(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: When to use cascading deletes?
Date: 2009-06-11 08:59:35
Message-ID: 18c1e6480906110159t4e76323cs49f5d0b827073c4f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there.

When is a good time to use cascading deletes?

Usually, for safety reasons, I prefer to not ever use cascading
deletes. But that can lead to some complex code that uses topological
sorts etc to manually delete records in the right order, when a
cascading delete is needed.

Ideally, I'd like postgresql to not do cascading deletes, *except*
when I tell it to, and the rest of the time fail when the user didn't
explicitly "opt in" for cascading deletes. When it comes to enabling
cascading deletes, I don't really like the idea that deleting or
updating a row from one table can have a possibly unexpected (to the
app programmer, using the database) chain reaction to other tables.

I don't know, maybe I have the wrong mindset, and cascading is
preferable (in terms of object model) in some cases? I'd like to read
more on this subject (general best practices for what types of
cascading are appropriate to use when).

Any tips?

Thanks,

David.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sim Zacks 2009-06-11 09:06:41 sort by update
Previous Message Dave Page 2009-06-11 07:54:24 Re: [sfpug] "Rails and PostgreSQL" now up on media.postgresql.org