RE: Inheritance question - Mailing list pgsql-general

From Stoppel, Brett W
Subject RE: Inheritance question
Date
Msg-id AA33E10E16DAD411BDFD0008C7CF50E602C1A4EC@hawk.mail.ukans.edu
Whole thread Raw
In response to Inheritance question  (msteele@inet-interactif.com)
List pgsql-general
Here is an example:

create table rectangle (x int, y int);
create table box (z int) inherits (rectangle);

Rectangle
 x  | Y
--------
 1  | 2
 2  | 3
 10 | 4

Box
 x  | Y  | z
-------------
 1  | 2  | 1
 2  | 3  | 12

Now you can select results from both tables with one easy query:

select x,y from rectangle*;

Results
 x  | Y
--------
 1  | 2
 2  | 3
 10 | 4
 1  | 2
 2  | 3

I know this isn't that practical of an example, but it is simple enough that
you can understand. Hope this helps.

Brett

-----Original Message-----
From: msteele@inet-interactif.com [mailto:msteele@inet-interactif.com]
Sent: Wednesday, 18 April, 2001 15:30
To: pgsql-general@postgresql.org
Subject: [GENERAL] Inheritance question



Hi folks, I've got a question regarding inheritance.

What are the advantages of using inheritance in the database
structure as opposed to using foreign keys? Doesn't
interitance mean that there will be much more duplication
of data in the database?

If anyone has any examples of proper usage of inheritance,
please let met know. I've read the docs, and haven't
puzzled out the usefulness of inheritance.

Thanks,

--
Mark Steele
Vice president research and development
Inet Technologies Inc.
msteele@inet-interactif.com

0101100101101111011101010010000001100001011100100110010100100000011001000111
01010110110101100010

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

pgsql-general by date:

Previous
From: "Oliver Elphick"
Date:
Subject: Re: Inheritance question
Next
From: Tom Lane
Date:
Subject: Re: backup with blobs