On Sat, 2010-03-20 at 11:40 -0400, Jason Pruim wrote:

> I know you are all probably thinking "What does this have to do with  
> PHP?" and in reality... It's probably stretching it a little bit...  
> BUT I am in the process of writing a blog software (Yes I'm aware of  
> all the open source, and paid stuff out there... I'm doing this to  
> learn :)) I am looking at adding "categories" to my blog posts so I  
> can organize my drivel into something that looks somewhat  
> professional, or at the very least, organized so you can filter out  
> all the crap...
> 
> What I'm wondering about though, is would it be better from a database  
> design stand point to do a database field for "categories" and then in  
> there put "Personal", "Business", "Crap I found funny"  Basically 1  
> database field for all the categories I decide to use. OR should I go  
> the other route and do 1 database field for each category?
> 
> This is going to be a small blog to start, but I guess I should always  
> be looking at performance, security, & maintainability right?
> 
> I did read the post that tedd put up about looking at storing  
> variables differently and am considering going that route... But just  
> wanted to know what you all think :)
> 
> Oh.... I'm also not expecting to have more then 4 or 5 categories at  
> the most.... Unless I release the blog to the public and take  
> wordpress down :P
> 
> So any help would be greatly appreciated :)
> 
> Thanks yall!
> 
> Jason Pruim
> 
> 
> 


I'd go with a new table for storing the categories in, and store the id
for the corresponding category in the blog table. That way, you can add
new categories easily later, pull out records quickly by category and
update category labels easily at any time.

This also allows you to develop the blog further in the future and allow
a blog post to have more than one category by introducing a third table
for category links, which can store blog post id's with the category
id's.

Thanks,
Ash
http://www.ashleysheridan.co.uk


Reply via email to