From: Ferruccio Zamuner <solo3@mail.chierinet.it>
To: pgsql-sql@hub.org
Subject: Nested classes
Date: Tue, 28 Jul 1998 08:05:51 +0100
Message-ID: <yam7513.2594.137981104@mail.chierinet.it> (raw)
Hi all,
I want to define one class as compound object of user defined classes and
basic types.
something like:
CREATE TABLE attributes {
Strenght int,
Health int,
Mana int,
Inteligence int
};
CREATE TABLE character {
Name text,
Role text,
Damage int,
Defense int,
Age int,
Attributes attributes
};
CREATE TABLE player {
Name text,
Age int,
Telephone text,
Character character
};
This is something like defining a C++ class with other user-defined classes as
attributes (no derivation, but containment).
Postgres 6.3.1 accepts the definitions above but the problems come when I want
to insert records of "player" type.
I have the following questions:
1. Is there any syntactic sugar (as { } for arrays) for INSERTing a new
"player" including its Character sub-object?
2. what about the same problem using a COPY to populate the DB from ascii
file?
3. after eventually having populated the DB, I'd like to write something like:
SELECT Character.Name, Character.Attributes.Intelligence FROM player
WHERE Age<18 AND Character.Age > 25;
to extract the name and intelligence of all the characters older than 25
played by people younger than 18
I know that some form of composite classes can be defined inserting OIDs of
sub-objects as attributes but this seems a bit weak and tricky solution. Is
there a better one?
Thanks in advance
Ferruccio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: solo3@mail.chierinet.it, pgsql-sql@hub.org
Subject: Re: Nested classes
In-Reply-To: <yam7513.2594.137981104@mail.chierinet.it>
References: <yam7513.2594.137981104@mail.chierinet.it>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox