Received: from megazone.bigpanda.com ([63.150.15.178]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fAP46Km62674 for ; Sat, 24 Nov 2001 23:06:20 -0500 (EST) (envelope-from sszabo@megazone23.bigpanda.com) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 36B15D5E5; Sat, 24 Nov 2001 20:06:25 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 2A4F85BE5; Sat, 24 Nov 2001 20:06:25 -0800 (PST) Date: Sat, 24 Nov 2001 20:06:25 -0800 (PST) From: Stephan Szabo To: Trond Arve Nordheim Cc: Subject: Re: Automaticly delete related data In-Reply-To: <1006654229.11145.8.camel@geekpower> Message-ID: <20011124200502.L97583-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200111/352 X-Sequence-Number: 5734 On 25 Nov 2001, Trond Arve Nordheim wrote: > Hi! > > I'm developing a publishing system and are trying to create > functions/triggers that automaticly wipes out related data to the data > currently beeing deleted... > > For example, I have a table containing site objects (an article or > whatever) where I have the following fields; > > int_objectid SERIAL NOT NULL, > str_objecttitle VARCHAR(255) NOT NULL, > ... > ... > > Then, I have a table defining the content of that data; > int_objectid INT(11) NOT NULL > str_data TEXT NOT NULL, > ... > ... > > What I want to do is; > When I delete a row from the first table, I want all rows with mathing > int_objectid values in the second table to be deleted. > > I've been reading in a couple of online books and the PostgreSQL > documentation all day without beeing able to make something of this... > > Can anyone give me a hint, or point me in the direction of some > documentation that can help me out? If you don't mind the other semantics, you can use foreign keys to handle this for you with the on delete cascade referential action.