Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [GENERAL] postgresql table inheritance

From: Martijn van Oosterhout <kleptog(at)svana.org>
Date: Fri Nov 30 2007 - 09:20:57 EST


On Fri, Nov 30, 2007 at 09:42:53PM +0800, Lincoln Yeoh wrote:
> Found this post on Slashdot which I found interesting, any comments?

I think this person is slightly confused.

> 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)?

Easy, by having the columns of one table be a subset of the columns or another table. Perhaps someone should point out an example, like a table with "people" and subtables "employees" and "customers". The subtables share the columns of the parent tables. This is nothing that any OO language doesn't do.

> 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:

His example is a little wierd, but it is possible:

test=# create type foo as (a text, b text); CREATE TYPE
test=# create table test( id int4, vals foo ); CREATE TABLE
test=# insert into test values ( 4, ROW('a', 'b')); INSERT 0 1
test=# select * from test;
 id | vals
----+-------
  4 | (a,b)
(1 row)

The syntax is different but the ideas are there...

Do you need help?X

Have a nice day,

-- 
Martijn van Oosterhout   <
kleptog(at)svana.org>   
http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
> -- John F Kennedy
Received on Fri Nov 30 09:22:16 2007

This archive was generated by hypermail 2.1.8 : Mon Jun 16 2008 - 20:59:44 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library