Re: Male/female

From: Berend Tober <btober(at)seaworthysys(dot)com>
To: Raymond O'Donnell <rod(at)iol(dot)ie>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Male/female
Date: 2006-12-08 15:36:13
Message-ID: 4579866D.1000102@seaworthysys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Raymond O'Donnell wrote:
> Just wondering.....how do list member represent gender when storing
> details of people in a database?
>
> I've done it two ways:
>
> * A bool column, with the understanding that true/false represents
> one gender or the other.
>
> * Create a domain, something like:
> CREATE DOMAIN gender_domain
> AS character varying(7)
> NOT NULL
> CONSTRAINT gender_domain_check CHECK ((((VALUE)::text =
> 'male'::text) OR ((VALUE)::text = 'Female'::text)))
>
> I personally prefer the second, as it's self-documenting...is there
> any other/better way of doing it?
>

--
-- PostgreSQL database dump
--

CREATE TABLE gender (
gender_pk SERIAL,
gender character varying(9) NOT NULL
);

COMMENT ON TABLE gender IS 'This table defines currently valid gender
types (and allows for god knows what..).';

COPY gender (gender_pk, gender) FROM stdin;
0 (unknown)
1 Male
2 Female
3 Trans
\.

ALTER TABLE ONLY gender ADD CONSTRAINT gender_pkey PRIMARY KEY (gender_pk);

In response to

  • Male/female at 2006-12-08 15:23:11 from Raymond O'Donnell

Responses

Browse pgsql-general by date

  From Date Subject
Next Message H.J. Sanders 2006-12-08 15:37:50 FW: Male/female
Previous Message Andreas Kretschmer 2006-12-08 15:35:43 Re: Male/female