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

Re: Composite UNIQUE across two tables?

From: "Dirk Jagdmann" <jagdmann(at)gmail(dot)com>
To: "Jamie Tufnell" <diesql(at)googlemail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Composite UNIQUE across two tables?
Date: 2008-03-13 06:16:59
Message-ID: 5d0f60990803122316v30c994cbm3b77a1c2c879d158@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
>  > My advise would be to have two triggers for insert/update on the site
>  > and users table that check the uniqueness of the username with the
>  > site_group. A have made some tests with inserts and updates on the
>  > existing users and sites and these two functions seem to work.
>
>  I think this is the way that I'll go.  I'd hoped to somehow express this
>  solely in the design, if you know what i mean (e.g. without writing
>  SPs), but it looks like this is the best way to do it.

Well I thought about that, but finally came to the conclusion, that
standard SQL constraints can not express this inter-table
relationships. As I'm not a fan of (artificially) breaking up tables I
just wrote those two pl/pgsql functions, because I'd rather have a
simple table design and some complicated constraint checking functions
than the other way.

>  Thank you for your taking the time to write this up, it's very much
>  appreciated.

Most people reading this list like to think about/learn from other
people's problems.

-- 
---> Dirk Jagdmann
----> http://cubic.org/~doj
-----> http://llg.cubic.org

In response to

pgsql-sql by date

Next:From: Bart DegryseDate: 2008-03-13 13:46:14
Subject: Re: in() VS exists()
Previous:From: Jamie TufnellDate: 2008-03-13 02:42:49
Subject: Re: Composite UNIQUE across two tables?

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