Return-Path: owner-postman
Received: from localhost.Berkeley.EDU (localhost.Berkeley.EDU [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with SMTP id DAA17234 for postgres-redist; Mon, 27 Mar 1995 03:47:06 -0800
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199503271147.DAA17234@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost.Berkeley.EDU didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from goliat.upc.es (goliat.upc.es [147.83.20.20]) by nobozo.CS.Berkeley.EDU (8.6.10/8.6.3) with SMTP id DAA17224 for <postgres@postgres.berkeley.edu>; Mon, 27 Mar 1995 03:46:18 -0800
Received: from mestral by goliat.upc.es (4.1/SMI-4.1)
	id AA10960; Mon, 27 Mar 95 13:40:41 +0200
From: fbd1@goliat.upc.es (practica fbd)
Message-Id: <9503271140.AA10960@goliat.upc.es>
Subject: A little question
To: postgres@postgres.Berkeley.EDU
Date: Mon, 27 Mar 1995 13:40:39 +0200 (MET DST)
X-Mailer: ELM [version 2.4 PL17]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 1306      
Resent-To: postgres-redist@postgres.Berkeley.EDU
Resent-Date: Mon, 27 Mar 95 03:47:06 -0800
Resent-XMts: smtp

	Hello, we are 3 students from Barcelona who are working with
Postgres 4.1. We have the next problem:

* We need to make reference from an object to another one, using some
kind of 'foreing key' but in a more object oriented style, and we don't
know how. We first tried to do this stuff: 

	create Thing (.....)\g
	create SubThing (reference_to_Thing = Thing)\g

and the answer was:

NOTICE:Mar 27 13:23:19:cannot create attribute of type Thing
WARN:Mar 27 13:23:19:use functions to get complex objects

Therefore we tried another solution which seems to work:

create People (name = text,
	       kmother = oid,
	       age = int4) \g

define function mother
(language = "postquel", returntype = People)
arg is (People)
as "retrieve (p.all)  
    from p in People
    where p.oid = $1.kmother" \g

append People (name = "Hillary Clinton", age = "40") \g
append People (name = "Chelsea Clinton", age = "14", 
		 kmother = p.oid)
from p in People
where p.name = "Hillary Clinton" \g

As we said before this works, but  is this the best way (the most
correct) to do it in Postgres?

			Thank You for your collaboration.

			Pedro, Oscar & Eduard : Postgres Team
			e-mail: fbd1@lsi.upc.es
			Facultat d'Informatica de Barcelona (F.I.B.),
			Universitat Politecnica de Catalunya (U.P.C.),
			Barcelona, Spain

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU".
   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
              URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres/
