Re: Is there a bitfield type field in oracle?

From: Walt <>
Date: Wed, 30 Jan 2008 13:00:53 -0500
Message-ID: <>

dean wrote:

> I have a general question here on how best to implement this: We have
> a table called TRAIN that holds around 10K records of railroad data. A
> client of ours wants to be able add a field that specifies which of
> the 365 days of a year the train runs.
> I can think of a few ways of doing this:
> 1) Add 365 fields of varchar2(1), each of which holds a 'Y' or a 'N'
> entry to state whether the train runs that day.
> 2) Add a foreign key to an external table that holds unique date
> ranges.
> 3) Is there a bitmap-kind of field that could hold one entry in a bit
> of an integer type. Such things are available to software developers
> who need to compress the data as much as possible.
> I'd appreciate a pointer to the right area here, if (3) is available.

Well, you could use a varchar2 of length 365 and enter strings of zeros and ones (or Y's and N's) Of course, I'd only recommend this if you were planning on leaving the project soon and you really hate the people who'll pick it up.

I'm having a hard time deciding whether this is better or worse than option 1.

My $.02 is that anytime you're using dates, use the Oracle DATE datatype so you don't have to reinvent the wheel regarding things like leap years, how many days are in a month, which day of the week it is, formatting the user output etc.

Also, it's a one-to-many relationship (one train, many days). So use a table.

//Walt Received on Wed Jan 30 2008 - 12:00:53 CST

Original text of this message