Re: SQL3 UNDER
Hannu Krosing <hannu@tm.ee>
From: Hannu Krosing <hannu@tm.ee>
To: "Robert B. Easter" <reaster@comptechnews.com>
Cc: Chris Bitmead <chris@bitmead.com>, pgsql-hackers@postgresql.org
Date: 2000-05-23T16:14:08Z
Lists: pgsql-hackers
"Robert B. Easter" wrote:
>
> On Tue, 23 May 2000, Chris Bitmead wrote:
> > Maybe it would help if you have two examples. One that only uses UNDER,
> > and one that only uses INHERITS, and explain how one or the other can
> > work differently.
>
> Which one (or both) that you use depends on the relationship the two entities
> have. If you need multiple inheritance, your choice is clear: INHERITS. UNDER
> will not do multiple inheritance.
> UNDER is the choice when the idea is of EXTENDing a class into more
> specific types of subclasses. INHERIT is the choice when the idea is like
> parent and child or olddesign and newdesign where olddesign may disappear
> without any problem.
>
> What follows are some rough examples. There could be some errors. I'd like to
> see someone elses examples too. I know there are possibilities for very good
> examples.
>
> CREATE TABLE powersource (
> );
> CREATE TABLE nuclearpowersource (
> ) UNDER powersource;
> CREATE fissionpowersource (
> ) UNDER nuclearpowersource;
> CREATE fusionpowersource (
> ) UNDER nuclearpowersource;
This is what INHERITS currently is meant for.
> CREATE TABLE machine (
> );
> CREATE TABLE poweredmachine (
> ) INHERITS(powersource) UNDER machine ;
Why not just
CREATE TABLE poweredmachine (
machine_powersource powersource
) UNDER machine ;
This should probably allow to insert any powersource as machine_powersource.
-------
Hannu