Re: Table inheritance versus views - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: Table inheritance versus views
Date
Msg-id 1028380244.2210.12.camel@rh72.home.ee
Whole thread Raw
In response to Table inheritance versus views  (cbbrowne@cbbrowne.com)
Responses Re: Table inheritance versus views  (Curt Sampson <cjs@cynic.net>)
List pgsql-hackers
On Fri, 2002-08-02 at 22:39, cbbrowne@cbbrowne.com wrote:
> On 29 Jul 2002 18:27:40 MDT, the world broke into rejoicing as
> Stephen Deasey <stephen@bollocks.net>  said:
> > Curt Sampson wrote:
> >> I'm still waiting to find out just what advantage table inheritance
> >> offers. I've asked a couple of times here, and nobody has even
> >> started to come up with anything.
> 
> > Table inheritance offers data model extensibility.  New (derived) tables
> > can be added to the system, and will work with existing code that
> > operates on the base tables, without having to hack up all the code.
> 
> But it kind of begs the question of why you're creating the new table in
> the first place.
> 
> The new table certainly _won't_ work with existing code, at least from
> the perspective that the existing code doesn't _refer_ to that table.

The beuty of OO is that it does not need to :

hannu=# create table animal (name text, legcount int);
CREATE
hannu=# insert into animal values('pig',4);
INSERT 34183 1
hannu=# select * from animal;name | legcount 
------+----------pig  |        4
(1 row)

hannu=# create table bird (wingcount int) inherits (animal);
CREATE
hannu=# insert into bird values('hen',2,2);
INSERT 34189 1
hannu=# select * from animal;name | legcount 
------+----------pig  |        4hen  |        2
(2 rows)

------------------
Hannu



pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: getpid() function
Next
From: Hannu Krosing
Date:
Subject: Re: Why is MySQL more chosen over PostgreSQL?