Re: delete cascade not working - Mailing list pgsql-general

From Joshua Tolley
Subject Re: delete cascade not working
Date
Msg-id 20090425205705.GC15830@eddie
Whole thread Raw
In response to Re: delete cascade not working  (Kenneth Tilton <kentilton@gmail.com>)
List pgsql-general
On Sat, Apr 25, 2009 at 04:21:06PM -0400, Kenneth Tilton wrote:
> But I am "inheriting" from the parent, so everything about the parent
> should be true for me unless overridden. I mean in the usual sense of
> inherit I know from OO.

This is from the current docs
(http://www.postgresql.org/docs/current/static/ddl-inherit.html):

"All check constraints and not-null constraints on a parent table are
automatically inherited by its children. Other types of constraints
(unique, primary key, and foreign key constraints) are not inherited."

Although it's easy to imagine otherwise, really inheritance structures
are made up of individual tables, and for the most part behave no
differently from any other tables. Indexes, constraints, etc. on the
parent table do not apply to data in child tables. The documentation
snippet above really means that when a new child table is created, check
constraints and not null constraints are automatically created to
correspond with those on the parent. Don't let yourself start thinking
inheritance in PostgreSQL behaves too similarly to inheritance in, say,
most programming language. Inheritance works nicely for partitioning;
most people that try to apply table inheritance to the same sorts of
scenarios where they'd apply inheritance in a programming language come
to find that it's more of a pain that it's worth.

- Josh / eggyknap

Attachment

pgsql-general by date:

Previous
From: Kenneth Tilton
Date:
Subject: Re: delete cascade not working
Next
From: Wang Kuo-Ying
Date:
Subject: PostgreSQL vacuumdb question