postgresql table inheritance - Mailing list pgsql-general

From Lincoln Yeoh
Subject postgresql table inheritance
Date
Msg-id 200711301348.lAUDmOQS058274@smtp9.jaring.my
Whole thread Raw
Responses Re: postgresql table inheritance  (Martijn van Oosterhout <kleptog@svana.org>)
Re: postgresql table inheritance  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Re: postgresql table inheritance  ("Peter Childs" <peterachilds@gmail.com>)
Re: postgresql table inheritance  (Gregory Stark <stark@enterprisedb.com>)
Re: postgresql table inheritance  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
Hi,

Found this post on Slashdot which I found interesting, any comments?

--- post follows ---
by Anonymous Coward on Wed Nov 28, '07 03:23 PM (#21509173)

Speak for your database -- postgresql does.

Postgresql's "table inheritance" is a flawed concept and has nothing to do
with the *type system*. Relations contain tuples, and tuples contain
attributes, which are a name plus a VALUE. Those values are chosen from TYPES
(sets of possible values). Those types are the TYPE SYSTEM.

Table inheritence doesn't even make sense. Tables are analogous to relations.
All relations are the same type, the relation type (think "set" or "array" to
make it easier). How can one value of a type (one table) be a subtype of
another value (another table)? That's like saying, "3" is a subtype of "5",
if your types are integers. What if you use the expression "3+2" Is that "5"
still the subtype of 3? likewise, when you make complex queries with a "base"
table, does the result have any connection with the "sub" table? It's like
gobbledygook, just mashing words together without any understanding. That's
why the postgresql table inheritance concept doesn't see more widespread use.
Many people quickly discover the limitations (and incorrectly think it's just
"unfinished", when it actually is flawed).

The correct way to store types and subtypes in the database is to store them
in the columns. In other words, choose attribute VALUES from a TYPE SYSTEM.
Nothing else in the relational model needs to be changed. Something like
this, in hypothetical SQL-like language:

     CREATE TABLE People ( INT id, PERSON_CLASS person )

     p1 = PERSON_CLASS.new(name: "joe", etc)

     p2 = CUSTOMER_CLASS.new(name: "bob", etc) // assume CUSTOMER_CLASS
subclass of PERSON_CLASS

     INSERT INTO People VALUES (1, p1), (2, p2)

     SELECT person FROM People WHERE person.name = "bob"

     SELECT person, order FROM People JOIN Orders // can't do this in the
typical "object database"

This is a "solved problem" (see "The Third Manifesto"). It's just a matter of
getting somebody to implement it. But the vendors are clueless, thinking
object databases are a "different model" and not wanting to confuse
programmers, and programmers are clueless, not even understanding SQL or
types and values half the time, so they don't demand anything new from
vendors... we never move forward.


pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: PostgresSQL vs Ingress
Next
From: Shane Ambler
Date:
Subject: Re: 1 cluster on several servers