Subject: Storage Model for Inherited Objects

From: <[email-masked]>
Date: Tue, 14 Jan 1992 15:49:48 -0600

----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Content-Lines: 29

Hello all,

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

I need to know since I am creating a large database application in which
inheritance makes sense, but if postgres does not perform this type
of normalization I am afraid my database will grow to be too large.
It seems my other option is to normalize the classes myself but then
I can't use inheritance.

Any help or suggestions are appreaciated.

Randy Johnston
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: .signature
X-Sun-Content-Lines: 4

Randy Johnston             MN11-1610
Alliant Techsystems Inc.,  Research and Technology Center
600 2nd Street N.E.,  Hopkins, MN  55343
[email-masked]       (612) 931-6084

---

From: postarch (Postgres Mailing Archive)
Date: Tue, 14 Jan 92 19:04:59 PST

>the instances of the data, or does it physically store those records

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
[email-masked]

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)")
                                                                     ^^^^^^^