You are here: Re: what is better - one field or eight - mysql bit testing « PHP Programming Language « IT news, forums, messages
Re: what is better - one field or eight - mysql bit testing

Posted by Dana Cartwright on 05/14/06 13:56

"windandwaves" <nfrancken@gmail.com> wrote in message
news:1147602781.523079.191310@j73g2000cwa.googlegroups.com...
> I have to store up to eight boolean bits of information about an item
> in my database.
> There are three ways of storing this information in my mysql database
> A. add eight fields (tiny integer)
> B. add one tiny integer and create a function in PHP that can translate
> the number stored into a eight boolean values (the bits)
> C. create a table which list
> ItemID
> Associated characteristics
> In C, you will only list the characteristics that are true for the item
> listed.
>
> Option B is the most efficient in MySql, but would you recommend it
> when creating a PHP website. The problem is that the user needs to
> enter them with a nice webform, etc...

Do you want to know which of these options is "best"? If so, you need to
define "best". And if you define "best", I suspect you'll have answered
your own question.

If you simply want something that works, flip a coin. They all "work".
Your biggest challenge in this case would be to find a 3-sided coin, of
course.

My experience with projects suggests strongly that your current eight fields
will grow in number. This always seems to happen. So you might consider
which of these schemes is the easiest to grow. Note that "B" is tricky
because it doesn't scale up very well (you run out of bits fairly quickly).

Also, consider a more philosophical question: why are you considering
storing the information as bits? I assume the answer is "because it's
possible to do so". What if your eight characteristics were not boolean?
What if they were, say, ternary? In that case, you would probably not store
them as bits, even though ternary data does, in the final analysis, always
get stored as bits. Ask yourself whether it makes sense to change the
storage method just because your particular characteristics are boolean?

-- Dana

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация