Re: Re: 7.1.2 ERROR: UNIQUE constraint matching given keys for referenced table ......

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Lincy <Lincy(dot)Lin(at)LinuxInBox(dot)Com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: 7.1.2 ERROR: UNIQUE constraint matching given keys for referenced table ......
Date: 2001-07-04 00:17:06
Message-ID: Pine.BSF.4.21.0107031713310.62456-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 26 Jun 2001, Lincy wrote:

> Ljb :
>
> Thanks your help. Look like add the UNIQUE constraint on it can solve
> this problem. Now I know what the problem is. But since our system must
> handle multi-company in same time. So we can't let department to be UNIQUE.
> What we try to using references in EmployeeInfo are just for check the
> department was exist or not. So, we will try to using trigger to do this
> check. Well, if need to write our own trigger for each table, we have lots
> work to do. :(

If department can't be unique (presumably because two companies could have
the same department name) then wouldn't you want to know what company the
employee and department belong to? If so, then the key should be both the
company and department (unless you're allowing one company to have
multiple departments of the same name) which would then be legally unique
and referenceable.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2001-07-04 00:33:44 Re: [PATCH] Partial indicies almost working (I think)
Previous Message Tom Lane 2001-07-03 23:08:56 Re: plpgsql and COPY