RE: Inheritance question

From: "Stoppel, Brett W" <bstoppel(at)ku(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: RE: Inheritance question
Date: 2001-04-18 22:01:24
Message-ID: AA33E10E16DAD411BDFD0008C7CF50E602C1A4EC@hawk.mail.ukans.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)inet-interactif(dot)com [mailto:msteele(at)inet-interactif(dot)com]
Sent: Wednesday, 18 April, 2001 15:30
To: pgsql-general(at)postgresql(dot)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(at)inet-interactif(dot)com

0101100101101111011101010010000001100001011100100110010100100000011001000111
01010110110101100010

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

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-04-18 22:07:33 Re: backup with blobs
Previous Message Oliver Elphick 2001-04-18 21:59:39 Re: Inheritance question