Using bitwise operator vs. mapping table

From: Brian Ghidinelli <brian(at)pukkasoft(dot)com>
To: sfpug(at)postgresql(dot)org
Subject: Using bitwise operator vs. mapping table
Date: 2007-10-14 00:37:05
Message-ID: 471164B1.8020909@pukkasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sfpug


Gurus,

I'm looking for some guidance on deciding between using a bitwise scheme
or a mapping table. I have an "events" table with "type" and a
corresponding "types" definition table. I want to change from one type
per event to many. I am considering:

1. Storing the types as bits in the "events" table. I can join them
with "where types.type & events.type = types.type"

2. Using a mapping table like "eventsToTypes" to connect the two tables.

I am more familiar with the second method but I like the bits approach
because it lets me do things like search for "any of the following event
types" very easily and the number of types of events is limited to what
will fit in a 32-bit integer.

Any thoughts? How does that type of bitwise operation perform in
comparison to the mapping table (where the key may be either an integer
or a UUID)?

Thanks,

Brian

Responses

Browse sfpug by date

  From Date Subject
Next Message Josh Berkus 2007-10-14 21:07:19 Re: Using bitwise operator vs. mapping table
Previous Message Quinn Weaver 2007-10-12 21:42:33 Sean Chittenden talk slides?