Re: Unique constraint on field inside composite type.

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Silk Parrot <silkparrot(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Unique constraint on field inside composite type.
Date: 2016-08-22 20:44:54
Message-ID: 20160822204454.GA32539@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 17, 2016 at 23:02:53 -0700,
Silk Parrot <silkparrot(at)gmail(dot)com> wrote:
>Hi,
>
>    I am trying to model a social login application. The application can support multiple login providers. I am thinking of creating a custom type for each provider. e.g.
>
>CREATE TABLE user (
>    uuid UUID PRIMARY KEY DEFAULT public.uuid_generate_v4(),
>    google_user system.google_user,
>    facebook_user system.facebook_user,
>    UNIQUE (google_user.email)
>);

Wouldn't it more sense to have a table you join to your user table that
is more flexible and allows for multiple entries per person. You would
need user, domain, foreign_user, auth_method. This would make it a lot
easier to add other systems later or let users pick their own systems
that you don't need to know about in advance.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-08-23 00:42:56 Re: Unique constraint on field inside composite type.
Previous Message Jeff Janes 2016-08-22 20:13:04 Re: Why insertion throughput can be reduced with an increase of batch size?