Skip site navigation (1) Skip section navigation (2)

Multitable uniqueness ?

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Multitable uniqueness ?
Date: 2004-05-26 03:13:14
Message-ID: 40B40B4A.4050908@gmx.net (view raw or flat)
Thread:
Lists: pgsql-sql
Hi folks,

Is there a way to have something like this :  UNIQUE (table_1.id, 
table_2.xxx)

I got some tables that have a couple of foreign keys. Now I try to 
minimize those relationships to clean up the mess.   :-}
We do business fairs. (???)  Like c-bit only a few magnitudes smaller.
So we have projects and rent stalls to customers.

customers (c_id, ...)
projects (p_id,...)

there is an relation    cust_proj (cp_id,  c_fk, p_fk, status_fk)
with a UNIQUE constraint  (c_fk, p_fk)

A customer can have several orders, contacts, ... tied to a project.

Those look like this   stalls (stall_id, cp_id, stall_no, ...)
o_id    PRIMARY
cp_fk  FOREIGN KEY that ties to custmer and project

stall_no   is a varchar
It should be unique within a project.

Will I have to integrate the project.id into the stalls-table ?



Responses

pgsql-sql by date

Next:From: hookDate: 2004-05-26 11:42:41
Subject: trigger function building
Previous:From: Tom LaneDate: 2004-05-24 13:37:37
Subject: Re: Memory usage on subselect

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group