Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6004A4761BF for ; Mon, 7 Oct 2002 11:47:45 -0400 (EDT) Received: from beamish.nsd.ca (unknown [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id 346D747614C for ; Mon, 7 Oct 2002 11:47:28 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id LAA06334; Mon, 7 Oct 2002 11:45:15 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma006332; Mon, 7 Oct 02 11:45:01 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id LAA03122; Mon, 7 Oct 2002 11:44:40 -0400 Message-ID: <3DA1AE5E.5BA92B6B@nsd.ca> Date: Mon, 07 Oct 2002 11:55:10 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-31 i686) X-Accept-Language: en MIME-Version: 1.0 To: "Rajesh Kumar Mallah." Cc: pgsql-sql@postgresql.org Subject: Re: enforcing with unique indexes.. References: <200210051219.07553.mallah@trade-india.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/91 X-Sequence-Number: 9809 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@postgresql.org)