On Tue, Mar 08, 2005 at 12:41:17AM -0500, cima wrote:
> is the following possible in postgresql 7.4?
>
> create table t1 (name varchar(10), age int2);
>
> create table t2 (position varchar(20), worker t1);
>
> if it is then how do i insert a record in t2?
The following doesn't work in 7.4.7 but it does work in 8.0.1:
INSERT INTO t2 VALUES ('position 1', row('name 1', 50));
SELECT * FROM t2;
position | worker
------------+---------------
position 1 | ("name 1",50)
(1 row)
SELECT position, (worker).name, (worker).age FROM t2;
position | name | age
------------+--------+-----
position 1 | name 1 | 50
(1 row)
> in the documentation i've read about object relational dbs there
> is some constructor involved but i'm not sure how to work with it.
The worker column holds values of a composite type but those values
aren't relations, if that's what you're looking for.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/