pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tille, Andreas <TilleA@rki.de>
Cc: PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: Re: Turning column into row
Date: Wed, 22 May 2002 16:36:22 +0200 (CEST)
Message-ID: <Pine.LNX.4.44.0205221629000.8932-100000@wr-linux02.rki.ivbb.bund.de> (raw)
In-Reply-To: <Pine.LNX.4.44.0205221448450.5109-100000@mailer.wurquhart.co.uk>

On Wed, 22 May 2002, Wm. G. Urquhart wrote:

> Not at all if you have for example 6 properties:
>
> Prop 1 = 1 ;
> Prop 2 = 2 ;
> Prop 3 = 4 ;
> Prop 4 = 8 ;
> Prop 5 = 16 ;
> Prop 6 = 32 ;
You are right, I have exactly 6 properties ;-) and actually for this
kind of application it is perfectly all right to proceed this way.
I do not put all of them not in separate columns but into one
column with the concatenated string
    Prop 1/Prop 3/Prop 6/
(and strip the remaining '/' afterwards).
While this solution is kind of a hack it fits my needs so far.

> The user will select the properties applicable to the Item; so for this
> example the new item has Properties 1, 3 and 6. These property values are
> added to give a total of 37. This is the value stored in the table column.
>
> Once you have the rows you can then && the Properties column to see if a
> property is set. I know this works as I've done it before in Oracle,
> Oracle even supports bitwise predicates. But I'm not sure if PostgreSQL
> does.
>
> if (Item.Column && Prop1)
>     Do this ;
> else
>    Property Not supported... ;
> end if ;
I see no reason why this should not work - but I even see no real
advantage to store a bitfield instead of just the concatenated string
in a temporary table which is removed afterwards anyway.

Thanks for the further hint

             Andreas.



view thread (15+ messages)  latest in thread

Message-ID: <Pine.LNX.4.44.0205221629000.8932-100000@wr-linux02.rki.ivbb.bund.de>
Permalink:  ../Pine.LNX.4.44.0205221629000.8932-100000@wr-linux02.rki.ivbb.bund.de/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0205221629000.8932-100000@wr-linux02.rki.ivbb.bund.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: TilleA@rki.de
  Subject: Re: Turning column into row
  In-Reply-To: <Pine.LNX.4.44.0205221629000.8932-100000@wr-linux02.rki.ivbb.bund.de>
  References: <Pine.LNX.4.44.0205221448450.5109-100000@mailer.wurquhart.co.uk> <Pine.LNX.4.44.0205221629000.8932-100000@wr-linux02.rki.ivbb.bund.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox