Re: Inheritance

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: Ian Turner <vectro(at)pipeline(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Inheritance
Date: 2000-07-30 05:23:09
Message-ID: 200007300523.e6U5NAA00803@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ian Turner wrote:
>Is there a way to set it up so that tables B and C are both children of
>table A, but where if you add records to B or C, they will show up in A as
>well (albiet without the extra fields provided by B and C)?
>
>In case that wasn't thouroughly confusing, allow me to try another
>analogy:
>
>CREATE TABLE Entities (num serial PRIMARY KEY);
>CREATE TABLE Corporations (name char(40));
>CREATE TABLE Players (name char(40),
> corp integer REFERENCES Corporations
>) INHERITS Entities;
>
>Now, if I insert something into players, like so:
>INSERT INTO Players (name) VALUES ('John');
>
>John WILL get a number pulled from the same set as the entity and
>corporation tables, but John WILL NOT show up in the entities table. Is
>there any way to get new entries in child tables to show up in the parent
>table?

`SELECT * FROM Entities*;'

up to and including 7.0.x.

In 7.1, I believe a select on the parent will automatically show the
children and you will need to do something like `SELECT * FROM ONLY Entities'
to exclude descendant tables.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"And Samuel said, Hath the LORD as great delight in
burnt offerings and sacrifices, as in obeying the
voice of the LORD? Behold, to obey is better than
sacrifice, and to hearken than the fat of rams."
I Samuel 15:22

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ian Turner 2000-07-30 06:44:41 Re: Inheritance
Previous Message Jouni Ahto 2000-07-30 01:40:53 Re: [PHP-INST] problem compiling php for pgsql