X-Original-To: pgsql-sql@postgresql.org Received: from localhost (unknown [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id F273A925902 for ; Thu, 22 May 2003 11:08:15 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 61361-10 for ; Thu, 22 May 2003 11:07:44 -0400 (EDT) Received: from smtp.ualg.pt (smtp.ualg.pt [193.136.224.8]) by developer.postgresql.org (Postfix) with ESMTP id A47AA9255C6 for ; Thu, 22 May 2003 05:10:21 -0400 (EDT) Received: from localhost (smtp.ualg.pt [127.0.0.1]) by smtp.ualg.pt (Postfix) with ESMTP id C78C64BE33; Thu, 22 May 2003 10:10:15 +0100 (WEST) Received: from smtp.ualg.pt ([127.0.0.1]) by localhost (smtp.ualg.pt [127.0.0.1]) (amavisd-new, port 10024) with SMTP id 30414-09; Thu, 22 May 2003 10:10:13 +0100 (WEST) Received: from ualg.pt (corisco.uceh.ualg.pt [10.10.20.126]) by smtp.ualg.pt (Postfix) with ESMTP id 366F54BDE4; Thu, 22 May 2003 10:10:13 +0100 (WEST) Message-ID: <3ECC93F7.60509@ualg.pt> Date: Thu, 22 May 2003 10:10:15 +0100 From: Luis Sousa User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021226 Debian/1.2.1-9 X-Accept-Language: en-pt MIME-Version: 1.0 To: Jan Wieck Cc: Richard Huxton , Filipe Bonjour , pgsql-sql@postgresql.org Subject: Re: Can arrays reference primary keys in CREATE TABLE? References: <200305141631.48642.dev@archonet.com> <3EC272D9.5050203@ualg.pt> <3EC91704.1080109@Yahoo.com> In-Reply-To: <3EC91704.1080109@Yahoo.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/416 X-Sequence-Number: 13581 Jan Wieck wrote: > Luis Sousa wrote: > >> Richard Huxton wrote: >> >>> On Friday 09 May 2003 10:21 pm, Filipe Bonjour wrote: >>> >>> >>>> Hi, >>>> >>>> I'm a rather new SQL user, and I found interesting that you can >>>> use "references" to make sure that a value inserted in a table is a >>>> primary key from another table. Something like: >>> >>> >>> >>> Yep - referential integrity is vital. >>> >> I used a trigger to get referential integrity. >> So, on update or insert, it fires the function that's going to read >> the new array and check if really exists on the other table > > > And what happens on UPDATE or DELETE to the primary key table? > > You used a trigger to check something, but unless you have a full set of > said triggers and they do the locking as well, you do not have > referential integrity. > > > Jan > > I guess you are right. I'll have to write a trigger for UPDATE or DELETE. How can I do the lock only on that record ? Luis Sousa