Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
Lists: sfpug

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)?




sfpug by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group