Received: from proxy.bazzanese.com (root@ip201.tol11.interbusiness.it [195.120.106.201]) by hub.org (8.8.8/8.7.5) with ESMTP id JAA24257 for ; Thu, 14 May 1998 09:05:09 -0400 (EDT) Received: from localhost (sferac@localhost) by proxy.bazzanese.com (8.8.8/8.8.8/Debian/GNU) with SMTP id KAA00741; Thu, 14 May 1998 10:57:09 GMT Date: Thu, 14 May 1998 10:57:09 +0000 (UTC) From: "Jose' Soares Da Silva" X-Sender: sferac@proxy.bazzanese.com To: Mike Lemler cc: pgsql-sql@postgreSQL.org Subject: Re: Referential Integrity In-Reply-To: <3.0.5.32.19980513152842.007a37a0@datacruz.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 13 May 1998, Mike Lemler wrote: > I haven't been able to find documentation on how to implement referential > integrity between tables with postgres via sql. Could someone please post > an example. Thanks. > > Michael. > Table Constraint definition: [ CONSTRAINT name ] { PRIMARY KEY constraint | UNIQUE constraint | CHECK constraint } Column Constraint definition: [ CONSTRAINT name ] { NOT NULL constraint | PRIMARY KEY constraint | UNIQUE constraint | CHECK constraint } examples: --defines a CHECK column constraint: -- CREATE TABLE distributors ( did DECIMAL(3) CHECK (did > 100), name VARCHAR(40) ); --defines a CHECK table constraint: -- CREATE TABLE distributors ( did DECIMAL(3), name VARCHAR(40) CONSTRAINT con1 CHECK (did > 100 AND name > '') ); PS: FOREIGN KEY is not implemented yet you can use TRIGGERS instead take a look at ...contrib/refint* Jose'