Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2DEAA47626B for ; Wed, 16 Oct 2002 13:15:02 -0400 (EDT) Received: from wilson.acpub.duke.edu (wilson.acpub.duke.edu [152.3.233.69]) by postgresql.org (Postfix) with ESMTP id 8D9954761FD for ; Wed, 16 Oct 2002 13:15:01 -0400 (EDT) Received: from pandorina.biology.duke.edu (pandorina.biology.duke.edu [152.3.11.26]) by wilson.acpub.duke.edu (8.12.4/8.12.4/Duke-5.0.0) with ESMTP id g9GHExWg008260; Wed, 16 Oct 2002 13:14:59 -0400 (EDT) Subject: Use of reference table ('look-up-table') and FK constraint From: Charles Hauser To: PSQL_list Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.3 (1.0.3-5.dulug.1) Date: 16 Oct 2002 13:14:59 -0400 Message-Id: <1034788500.414.63.camel@pandorina.biology.duke.edu> Mime-Version: 1.0 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/178 X-Sequence-Number: 9895 Hi, In fits and starts I am working through converting a sybase schema -> postgres and am hoping to gain some insight on the use of reference tables ('look-up-table') and FK constraints. In the example below I believe the sybase RULE Phone_type_rule is used to restrict input, so that the only values which can be inserted or updated into Phone have to be one of ('work', 'home', 'fax', 'mobile', 'lab', 'unknown'). How would this be accomplished using a look-up or reference table::FK constraint combination? CREATE RULE Phone_type_rule AS @col IN ('work', 'home', 'fax', 'mobile', 'lab', 'unknown') go CREATE TABLE Phone ( phone_id Identifier_type IDENTITY, phone_number varchar(20) NOT NULL, community_id numeric(12) NOT NULL, type varchar(10) NULL ) go exec sp_bindrule Phone_type_rule, 'Phone.type' go regards, Charles