From: | Joshua Tolley <eggyknap(at)gmail(dot)com> |
---|---|
To: | Kenneth Tilton <kentilton(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: delete cascade not working |
Date: | 2009-04-25 20:57:06 |
Message-ID: | 20090425205705.GC15830@eddie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Wang Kuo-Ying | 2009-04-26 03:27:34 | PostgreSQL vacuumdb question |
Previous Message | Kenneth Tilton | 2009-04-25 20:21:06 | Re: delete cascade not working |