Re: enforcing with unique indexes..

From: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
To: "Rajesh Kumar Mallah(dot)" <mallah(at)trade-india(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: enforcing with unique indexes..
Date: 2002-10-07 15:55:10
Message-ID: 3DA1AE5E.5BA92B6B@nsd.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Try a rule or a triger that checks for
NOT EXISTS ( select 1 from eyp_listing where group_id = New.group_id and
userid != New.userid)

"Rajesh Kumar Mallah." wrote:
>
> Hi ,
>
> can anyone tell me how can i enforce below in a table.
> I want that no more that one distinct userid exists for a given group_id
> in the table.
>
> ie i want 1 to 1 mapping between group_id and userid so that , there shud not be a
> single group_id having more that one kind of userid.
>
> SELECT group_id from eyp_listing group by group_id having count(distinct userid) > 1 ;
>
> always returns empty.
>
> can it be done with some sort of UNIQUE INDEX?
>
> Regds
> MAllah.
>
> --
> Rajesh Kumar Mallah,
> Project Manager (Development)
> Infocom Network Limited, New Delhi
> phone: +91(11)6152172 (221) (L) ,9811255597 (M)
>
> Visit http://www.trade-india.com ,
> India's Leading B2B eMarketplace.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-10-07 16:40:37 Re: Get A Tree from a table
Previous Message Manfred Koizar 2002-10-07 15:22:41 Re: Large databases, performance