Page 1 of 1

Random question: Which is faster/better

Posted: Sat Dec 15, 2007 12:20 pm
by aliasxneo
This is something I've been pondering for awhile.

Let's say I have some items that I want to categorize. I have a categories table that contains the category id and name. Would it be better if I:

A) Added a field called 'category' to the items table that contains the category id it belongs too
B) Created a new table that contains a game id and a category id ti show which game belong to which category

Is either one more appropriate or faster?

Posted: Sat Dec 15, 2007 12:30 pm
by nickvd
Option B would allow you to have a game in more than one category, whereas option A would limit each game to a single category...

As for speed, I doubt either would be substantially faster, but I am not the person to answer that kind of question...

Posted: Sat Dec 15, 2007 3:41 pm
by Weirdan
General rule of thumb: the more joins your query has, the more slower it runs. Thus second option will be somewhat slower, but it will provide additional functionality which first option coudn't provide.

Posted: Sat Dec 15, 2007 10:21 pm
by RobertGonzalez
Joins, though somewhat slower for larger data sets, can be made efficient with proper indexing and table normalization.

Posted: Sat Dec 15, 2007 10:23 pm
by John Cartwright
I will always choose normalization over performance. Hardware is simply cheaper than man power (aka the cost of maintaining and developing a poorly structured database).