Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA22082; Tue, 14 Jan 92 19:05:14 -0800
Message-Id: <9201150305.AA22082@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: Storage Model for Inherited Objects
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Reply-To: mer@postgres.berkeley.edu
In-Reply-To: Your message of "Tue, 14 Jan 92 15:49:48 CST."
             <92Jan14.154957cst.46092@nic.rtc.atk.com>
Date: Tue, 14 Jan 92 19:04:59 PST

you write:
>I have a question regarding the postgres storage system for inherited objects.
>
>I create the classes as follows:
>
>	create EMP (name=char[12], salary=float8, age=int4)
>	create STUD_EMP (location=point) inherits (EMP)
>
>And insert the data:
>
>	append STUD_EMP (name="joe", salary=1400.0, age=40, location=3,4)
>	append STUD_EMP (name="joe", salary=1400.0, age=40, location=5,6)
>
>Given the above does postgres only physically store the inherited EMP
>fields once with pointers or some other method used to keep track of
>the instances of the data, or does it physically store those records
>twice.?

If I understand you correctly, then the answer to your question is that
the above appends will cause two instances of STUD_EMP to exist in your
database.  No duplication of data occurs.  To access them from the EMP
class you need to use * in your from clause so that the system will walk
down the inheritance hierarchy:

	retrieve (e.all) from e in EMP* where e.salary > 1000.0

This should return the two instances appended above.  The magic is performed
by the planner (It plans union queries for all super-classes).


Jeff Meredith
mer@postgres.berekeley.edu

p.s.  Your syntax above is incorrect, it should be:

	append STUD_EMP (name="joe", salary=1400.0, age=40, location="(3,4)")
	append STUD_EMP (name="joe", salary=1400.0, age=40, location="(5,6)")
                                                                     ^^^^^^^
