From: Charles Hauser <chauser@duke.edu>
To: PSQL_list <pgsql-sql@postgresql.org>
Subject: Use of reference table ('look-up-table') and FK constraint
Date: 16 Oct 2002 13:14:59 -0400
Message-ID: <1034788500.414.63.camel@pandorina.biology.duke.edu> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: chauser@duke.edu
Subject: Re: Use of reference table ('look-up-table') and FK constraint
In-Reply-To: <1034788500.414.63.camel@pandorina.biology.duke.edu>
References: <1034788500.414.63.camel@pandorina.biology.duke.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox