Re: equivalent of mysql's SET type?

From: Darren Duncan <darren(at)darrenduncan(dot)net>
To: Reece Hart <reece(at)harts(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: equivalent of mysql's SET type?
Date: 2011-03-09 05:27:50
Message-ID: 4D770FD6.5050802@darrenduncan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Reece Hart wrote:
> On Tue, Mar 8, 2011 at 5:52 PM, Darren Duncan <darren(at)darrenduncan(dot)net>wrote:
>
>> Try starting with an enum type to define the possible values:
>>
>> CREATE TYPE Consequence_Type
>> AS ENUM ('ESSENTIAL_SPLICE_SITE','STOP_GAINED',
>> 'STOP_LOST','COMPLEX_INDEL','SPLICE_SITE');
>>
>> ... and then you could try using "ARRAY OF Consequence_Type" or some such.
>
> Arrays occurred to me, but they don't give a set (i.e., a consequence type
> can appear more than once) unless I write the code to dedupe the array.
> However, if I were going to put that much effort into it, I might as well
> represent the set directly and obviate the dedupe. Or, am I missing
> something from your suggestion?

You also have another option, which is to split consequence_type into
a second table, and have a record in there for each value in the set. You would
maintain a lack of duplicates by having an ordinary unique/primary key
constraint on the second table. This second-table approach is logically
equivalent to your use of a set-valued field. -- Darren Duncan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2011-03-09 05:41:31 Re: equivalent of mysql's SET type?
Previous Message Reece Hart 2011-03-09 04:54:52 Re: equivalent of mysql's SET type?