View Single Post
  #9 (permalink)  
Old 07-29-2007, 09:29 AM
molotov molotov is offline
Novice
Join Date: Jul 2007
Posts: 37
iTrader: (0)
molotov is on a distinguished road
Why are we trying to store the names of the categories with such large integers? I guess I don't understand why the key for the subject has to double each time. Why wouldn't we use an unsigned SMALLINT and assign the subjects like so:

0 => 'subject1',
35 => 'subject2',
70 => 'subject3'
etc.


Here are some of my clues which tell me 'maybe you don't understand yet molotov':
(emphasis mine, of course)
Quote:
In this article I will discuss an efficient algorithm (or methodology, if you prefer) for storing user choices which facilitates any subsequent decision-making processes from the perspective of PHP 5 OOP and MySQL. ... We'll also work under the assumption that categories have only one attribute, name. ... I'm not going to discuss most of the database model, just the part which is relevant to what we need: saving and searching through subjects as quickly as possible. That means the only real question which must be answered before we create the database is, "What type of field should subject be?" Well, we really only have three options to check out given it will be a single database field: char/varchar, enum, or integer.
I understand completely why you're getting funky numbers for Sports and Women's Fiction; once you get higher than 2^32, you're at the end of your php-rope when it comes to numbers.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote