Re: boolean or int2

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: <operationsengineer1(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: boolean or int2
Date: 2005-08-02 18:52:16
Message-ID: 20050802184850.M94644@narrowpathinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, 2 Aug 2005 10:31:17 -0700 (PDT), operationsengineer1 wrote
> i have a situation where widgets either pass or fail a
> test and i record the result.
>
> i'm thinking of using boolean to track this - true for
> pass, false for fail.
>
> i've used int2 in other situations b/c i couldn't be
> as sure that only two outcomes were possible. i could
> use int2 here, also (ie, 0 for fail, 1 for pass).
>
> does it make a practical difference which one i use?
>
> as always, thanks for the help. it is much appreciated.

Personally I like to use a boolean to make the code a little more self
documenting. With a column name like passed_test and a boolean your code ends
up looking like

WHERE passed_test

or

WHERE NOT passed_test

Kind Regards,
Keith

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2005-08-02 20:57:09 Re: Make year 01/01/0001 but leave timestamp alone
Previous Message Jeffrey Melloy 2005-08-02 18:34:28 Re: Strange Error on Table Creation Attempt