Re: enum, set - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: enum, set
Date
Msg-id 20030627011637.GA11951@wolff.to
Whole thread Raw
In response to enum, set  (M Spreij <nemo@mechintosh.com>)
List pgsql-novice
On Fri, Jun 27, 2003 at 03:04:45 +0200,
  M Spreij <nemo@mechintosh.com> wrote:
>   Just recently started using PostgreSQL, and there are some things
> I've that I've come to like in MySQL and wondering how to do those in
> PostgreSQL. (I know that I should also be looking at all PG's
> features that MySQL doesn't have, but.. ;-)
>   For example, the ENUM or SET column types, how would one go about
> porting/implementing those? I got this form where the admin needs to
> specify the possible methods of shipping, per country, from a bunch
> of checkboxes (these would be records in the shipping_methods table),
> but also add new ones (creating a new record in that table). All good
> so far, but how do I save the selection? Do I need to use the array
> datatype (rather not if possible..) ?
>   Using PHP/Apache.

The normal way to do this is with tables. You can have a table of
valid values for the enum type. (A domain with a check constraint
will work in 7.4. But you probably only want to do this if the set of
valid values very rarely changes.) The set type is handled by a table
that pairs enum values with keys from the table that is connected to
the set.

pgsql-novice by date:

Previous
From: Rudi Starcevic
Date:
Subject: Address Table
Next
From: Tom Lane
Date:
Subject: Re: Best Practice??