Received: from smtp1b.mail.yahoo.com (smtp3.mail.yahoo.com [128.11.68.135]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f0KN0R065921 for ; Sat, 20 Jan 2001 18:00:27 -0500 (EST) (envelope-from janwieck@yahoo.com) Received: from a5f6e.pppool.de (HELO jupiter.jw.home) (213.6.95.110) by smtp.mail.vip.suc.yahoo.com with SMTP; 20 Jan 2001 23:52:55 -0000 X-Apparently-From: Received: (from janwieck@localhost) by jupiter.jw.home (8.9.3/8.9.3) id RAA12172; Sat, 20 Jan 2001 17:13:27 -0500 From: Jan Wieck Message-Id: <200101202213.RAA12172@jupiter.jw.home> Subject: Re: unreferenced primary keys: garbage collection In-Reply-To: <4l5i6tcr56fkb8hob8a3bas3ce0qq53d6l@4ax.com> from Forest Wilkinson at "Jan 19, 2001 08:54:21 pm" To: Forest Wilkinson Date: Sat, 20 Jan 2001 17:13:27 -0500 (EST) CC: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200101/270 X-Sequence-Number: 939 Forest Wilkinson wrote: > I have a database in which five separate tables may (or may not) reference > any given row in a table of postal addresses. I am using the primary / > foreign key support in postgres 7 to represent these references. > > My problem is that, any time a reference is removed (either by deleting or > updating a row in one of the five referencing tables), no garbage > collection is being performed on the address table. That is, when the > last reference to an address record goes away, the record is not removed > from the address table. Over time, my database will fill up with > abandoned address records. While this behaviour makes sense in your case, it's not subject to referential integrity constraints. You could arrange for it with custom trigger procedures, checking all the five tables on DELETE or UPDATE on one of them. I'll make up a little example and post it the other day - need to take a nap now and tomorrow will be one of these 30-hour days (from MET to EST), so don't expect anything before Monday afternoon (EST). Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com