Use of reference table ('look-up-table') and FK constraint

Поиск
Список
Период
Сортировка
От Charles Hauser
Тема Use of reference table ('look-up-table') and FK constraint
Дата
Msg-id 1034788500.414.63.camel@pandorina.biology.duke.edu
обсуждение исходный текст
Ответы Re: Use of reference table ('look-up-table') and FK constraint
Re: Use of reference table ('look-up-table') and FK constraint
Список pgsql-sql
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')
goCREATE TABLE Phone (       phone_id             Identifier_type IDENTITY,       phone_number         varchar(20) NOT
NULL,      community_id         numeric(12) NOT NULL,       type                 varchar(10) NULL)
 
goexec sp_bindrule Phone_type_rule, 'Phone.type'
go
regards,

Charles






В списке pgsql-sql по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: replace null with 0 in subselect ?
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Use of reference table ('look-up-table') and FK constraint