On Oct 12, 2011, at 3:31 AM, Shorty wrote:

> Or is the speed difference so small it doesn't matter?

If you have a trivial amount of data, then it doesn't matter much either way. 
Anything goes when you have no data :)

But in general, do normalize your data and use foreign keys. There are numerous 
benefits in doing so. 

> Like instead of having "fruit" in the grocery_type column, I could have it as 
> a "1" type, vegetables would be "2", and then translate that just before 
> spitting out the table to my web page.

Yes, as pointed out by Simon, this is called normalization [1]. Which is a good 
thing to do, in the same way as designing a proper OO model is important when 
doing, well, OOP.

As far as performance goes, thing about normalization as a form of compression: 
for each discreet piece of information (e..g. grocery type) you assign a unique 
number to it. Then you always refer to that data using that unique number. So, 
say, instead of storing the literal 'vegetable' half-a-million time, you might 
just store its foreign key, say, 1. Same applies for any indices you might have 
on that column. Such "compression" add up quite quickly. You database engine 
will be grateful  :)

Tangentially related:

Double-thinking in SQL
http://explainextended.com/2009/07/12/double-thinking-in-sql/


[1] http://en.wikipedia.org/wiki/Database_normalization

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to