From: | Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | unique keys / foreign keys on two tables |
Date: | 2012-11-29 10:14:27 |
Message-ID: | 201211291014.27989.gary.stainburn@ringways.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Wolfe Whalen | 2012-11-29 11:13:17 | Re: unique keys / foreign keys on two tables |
Previous Message | Guillaume Lelarge | 2012-11-29 09:33:37 | Re: \copy multiline |