Re: Thus spoke SQL3 (on OO) - Mailing list pgsql-hackers

From Robert B. Easter
Subject Re: Thus spoke SQL3 (on OO)
Date
Msg-id 00052104000003.14806@comptechnews
Whole thread Raw
In response to Re: Thus spoke SQL3 (on OO)  (Chris <chris@bitmead.com>)
List pgsql-hackers
On Sat, 20 May 2000, Chris wrote:
> Boy. I think we should  look to how other people have implemented object
> models rather than how SQL3 describes the concept. This sounds like a
> nightmare.

SQL3 does not appear to really have an object model.  Rather, it appears to be
a hierarchial model on top of the relational model.  Section 4.16.2 (in 9075-2)
"Referenceable tables, subtables, and supertables" talks about "a leaf table",
if that clarifies anything.

Here is a quote (9075-2 4.16):
        Let T(a) be a maximal supertable and T be a subtable of T(a). The        set of all subtables of T(a) (which
includesT(a) itself) is called        the subtable family of T or (equivalently) of T(a). Every subtable        family
hasexactly one maximal supertable.
 
        A leaf table is a table that does not have any proper subtables.


Definitions (my interpretations anyway):
* Every table is a subtable and supertable of itself.

* A proper subtable (of a supertable) is a table that was CREATEd with an UNDER
clause that references its supertable - i.e, a proper subtable is just a
subtable that is not the supertable itself.

* A proper supertable (of a subtable) is a table that was specified in an
UNDER clause during creation of a subtable.

* A maximal supertable is a table that is not a subtable of any other table.


So, it says that every subtable family (or member of) has exactly one maximal
(root) supertable. This seems to make clear that multiple inheritance is not
allowed.  The picture of this hierarchy is inverted trees with the roots
at maximal supertables with subtables branching down, EXTENDing the
supertable.

Another quote (9075-2 4.16):
        Users must have the UNDER privilege on a table before they can use        the table in a subtable definition. A
tablecan have more than one        proper subtable. Similarly, a table can have more than one proper
supertable.


Ok, it can have more than one (proper) supertable.  This means that a chain
of inheritance is allowed: maximal supertable -> subtable1 -> (sub)subtable2
etc, where (sub)subtable2 has two supertables: maximal supertable and subtable1.

Only one table can be specified in the UNDER clause, which prevents the
following possibility:

(1)    subtable_a UNDER maximal_supertable
(2)    subtable_b UNDER maximal_supertable
(3)    subtable_abc UNDER subtable_a, subtable_b

(3) is not allowed, but if it where, then subtable_abc would still have had only one
maximal supertable.  If allowed, it would have inherited maximal supertable
twice.

Another quote (9075-2 4.16):
        The secondary effects of table updating operations on T on proper        supertables and subtables of T are as
follows:
        -  When row R is deleted from T, for every table ST that is a           proper supertable or proper subtable of
T,the corresponding           superrow or subrow SR of R in ST is deleted from ST.
 
        -  When row R is replaced in T, for every table ST that is a proper           supertable or a proper subtable
ofT the corresponding superrow           or subrow SR of R in ST is replaced in ST.
 
        -  When row R is inserted into T, for every proper supertable ST of           T the corresponding superrow SR
ofR is inserted into ST.
 


These effects describe a sharing of properties (columns) among the super and
subtables.  A row in a supertable may be part of a single row in 0 or 1 of its
subtables (if I got it right) - a 1:1 relationship if any.  The subtable and
supertable are linked together in the tree hierarchy and are not independent
after creation.  The subtable extends additional attributes onto the supertable.

Summing this up a little now, SQL3's UNDER clause appears to allow an EXTENDS
type of inheritance, which is like a hierarchial (tree) model.  It does not have
a general-pupose object-oriented capability.  It does not provide for the
CLONE and ASSIMILATE types of inheritance that I decribed in an earlier message
to this list.  As other messages have stated, UNDER is not too different than
what INHERITS currently does.  Actually, INHERITS allows multiple inheritance
too, so it does more right now (I guess).

Since INHERITS, as it is implemented now, is like SQL3's UNDER, maybe it should
NOT allow multiple inheritance and should strive to become UNDER if SQL3 is a
good idea.

If the other object-oriented methods, like CLONES and ASSIMILATES (or whatever
you want to call them), is ever wanted in PostgreSQL, then looks like some other
standard(s) will have to be drawn from.  I have not looked at the ODMG 3.0
(standard) yet.  But maybe it has the missing capabilities.  Is ODMG 3.0 an
international standard?  I'd like to just download it and read it, but looks
like you have to buy it for $39.95.

I hope my comments are useful. :)

-- 
Robert B. Easter
reaster@comptechnews.com


pgsql-hackers by date:

Previous
From: "Matthias Urlichs"
Date:
Subject: Re: MySQL's "crashme" (was Re: Performance)
Next
From: Chris
Date:
Subject: Re: Thus spoke SQL3 (on OO)