pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: pgsql-sql@postgresql.org
Subject: unique keys / foreign keys on two tables
Date: Thu, 29 Nov 2012 10:14:27 +0000
Message-ID: <201211291014.27989.gary.stainburn@ringways.co.uk> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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 


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (2+ messages)  latest in thread

Message-ID: <201211291014.27989.gary.stainburn@ringways.co.uk>
Permalink:  ../201211291014.27989.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/201211291014.27989.gary.stainburn@ringways.co.uk

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gary.stainburn@ringways.co.uk
  Subject: Re: unique keys / foreign keys on two tables
  In-Reply-To: <201211291014.27989.gary.stainburn@ringways.co.uk>

* 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