Re: unique in two not so unique columns

From: "Thomas T(dot) Thai" <tom(at)minnesota(dot)com>
To: Tino Wildenhain <tino(at)wildenhain(dot)de>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: unique in two not so unique columns
Date: 2002-11-02 09:37:27
Message-ID: Pine.NEB.4.43.0211020333260.16842-100000@ns01.minnesota.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2 Nov 2002, Tino Wildenhain wrote:

> Hi Thomas,
>
> --On Samstag, 2. November 2002 00:58 -0600 "Thomas T. Thai"
> <tom(at)minnesota(dot)com> wrote:
>
> > I have two columns in a table:
> >
> > email varchar(64)
> > verified boolean
> >
> > How do I make a check for unique email that is verified while allowing for
> > non-verified emails to be not unique?
>
> Before thinking of a solution for this in PG, I dont
> see why you need this requirement in the first place:
> whay should the very same e-mail be both verified and
> unveryfied? And even more - why should be more then one
> row telling you this very same e-mail is unverified?
>
> Is this only an example which does not serve very well
> or is there a bigger picture?

It's for a user authentication system. User registers, but I want to
verify their email address before allowing them access. There are more
fields in that table than what I showed (like userid, etc.).

If I don't verify their email address, then anyone can sign up and use
someone else's email address, there by preventing the ligitimate owner of
that email address to register in the system. Once the email address is
verified, I don't want other users trying to use that email address again.
I'm currently doing a SELECT to check the conditions, but I wanted a
backup solutions so it's more transaction safe.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hubert depesz Lubaczewski 2002-11-02 09:55:02 Re: problems with building recent cvs snaphots
Previous Message Tino Wildenhain 2002-11-02 09:33:09 Re: unique in two not so unique columns