unique keys / foreign keys on two tables

Поиск
Список
Период
Сортировка
От Gary Stainburn
Тема unique keys / foreign keys on two tables
Дата
Msg-id 201211291014.27989.gary.stainburn@ringways.co.uk
обсуждение исходный текст
Ответы Re: unique keys / foreign keys on two tables  (Wolfe Whalen <wolfe@quios.net>)
Список pgsql-sql
I'm designing the schema to store a config from our switchboards.

As with all PBX's the key is the dialed number which is either an extension 
number or a group (hunt/ring/pickup) number.

I have two tables, one for extensions and one for groups, basically

ext_id    int4 primary key
ext_desc    text
....
....
....

and



grp_id    int4 primary key
grp_desc    text
.....
.....
.....

I now need to be able to ensure the id field is unique across both tables. 
Presumably I can do this with a function and a constraint for each table. 
Does anyone have examples of this?


Next I have other tables that refer to *destinations* which will be an ID that 
could be either an extension or a group. Examples are 'Direct Dial In' 
numbers which could point to either.  How would I do that?

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 



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

Предыдущее
От: Guillaume Lelarge
Дата:
Сообщение: Re: \copy multiline
Следующее
От: Wolfe Whalen
Дата:
Сообщение: Re: unique keys / foreign keys on two tables