Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f5CGRwE38565 for ; Tue, 12 Jun 2001 12:27:58 -0400 (EDT) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f59GSlE87666 for ; Sat, 9 Jun 2001 12:28:47 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f59GGxQ78229 for pgsql-sql@postgresql.org; Sat, 9 Jun 2001 12:16:59 -0400 (EDT) (envelope-from news) From: "Postgresql" X-Newsgroups: comp.databases.postgresql.sql Subject: cascading delete - recursivity Date: Sat, 9 Jun 2001 18:22:51 +0200 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 22 Message-ID: <9fti5q$2ccg$1@news.tht.net> X-Complaints-To: scrappy@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 To: pgsql-sql@postgresql.org X-Archive-Number: 200106/180 X-Sequence-Number: 3404 Hi, I have a table of categories (it's pseudo-sql...) : CATEGORIES ( id_category PRIMARY KEY, id_category_parent (FOREIGN KEY ? CONSTRAINT ??) , cat_text ) There is recursivity : id_category_parent is -1 (= no parent cat) or the id_category of a category in this table. What is the SQL statements to create such a table so that when you delete a category, all sub-categories are automatically deleted ? I've tried many things like CONSTRAINT... but the query fails ! Thanks !