blog design issue...

blog design issue...

am 20.03.2010 16:40:59 von Jason Pruim

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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: blog design issue...

am 20.03.2010 16:50:48 von Ashley Sheridan

--=-0+ptGI4wK9M3MAv6cyoa
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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



--=-0+ptGI4wK9M3MAv6cyoa--

Re: blog design issue...

am 20.03.2010 17:06:32 von Richard

Hi,

> 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 look=
ing
> at adding "categories" to my blog posts so I can organize my drivel into
> something that looks somewhat professional, or at the very least, organiz=
ed
> 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 th=
ere
> put "Personal", "Business", "Crap I found funny" =A0Basically 1 database =
field
> for all the categories I decide to use. OR should I go the other route an=
d
> 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 kno=
w
> 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

You could use a SET field type. Internally MySQL uses numbers (a bit
mask IIRC) for them. Though you will be limited to 32 categories.

Eg:

Categories table:
ID Name
============
1 Personal
2 Business
4 Crap I found funny

Articles table:
ID Title Category
==================== ===3D
1 My first blog entry 1
2 A joke from work 6
3 A joke from home 5
4 A joke 4

The numbers are bitwise sums of the corresponding category IDs.
eg.4&2=3D6. I think. MySQL has some built in functions for dealing with
sets, like FIND_IN_SET() IIRC, which make life a lot easier.

--=20
Richard Heyes
HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 13th March)
Lots of PHP and Javascript code - http://www.phpguru.org

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: blog design issue...

am 20.03.2010 17:09:01 von Robert Cummings

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?

Give categories their own table, then it's simplistic to add more. Hard
coding it as a column undermines the point of joins in SQL and makes
your database design suck, not to mention your application ;)

> This is going to be a small blog to start, but I guess I should always
> be looking at performance, security, & maintainability right?

Always.

> 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 :)

Table!

> 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

It's not what you expect, it's what your users expect that counts. Learn
that and your software will be usable.

> So any help would be greatly appreciated :)

:)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: blog design issue...

am 20.03.2010 17:14:51 von Richard

Hi,

> eg.4&2=6.

Oops, that should be 4|2 = 6.

--
Richard Heyes
HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 13th March)
Lots of PHP and Javascript code - http://www.phpguru.org

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: blog design issue...

am 20.03.2010 18:55:28 von TedD

At 11:40 AM -0400 3/20/10, 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


Jason:

Basically whatever everyone else said, namely use a table to record
every category you may want and that practice provides:

1) Expansion;

You may want to add additional categories and adding it in one table
makes sense over adding it to one, or more, selection controls you
may have across your web site.

2) Changing the name of any category.

You may find later (after hundreds of blog entires) that the category
"Crap I found funny" has just been reviewed by your boss, wife, or
mother-in-law and they have demanded that you change it to something
more appropriate (according to them). If you used a table, then it's
a simple matter to change it over hundred's of post. However, if you
didn't, then you have a lot of work to do.

Another consideration.

I have a sort-of blog entry script I add to any page on my site where
I want people to comment (see http://sperling.com/examples/new-menuh/
for an example).

The coding to add this feature is a simple one line include
statement. The included script looks at the page where it has been
placed and creates a space for that page's related comments in the
database. After which, whenever that page is loaded, the script calls
out the appropriate entries and displays them. The entire process is
automagical.

The point I'm trying to express here is one of creating a script that
doesn't require any customization for use. This is just food for
thought when thinking about how to do this.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: blog design issue...

am 20.03.2010 19:03:56 von Dan McCullough

--0016e64de3cada841504823f4a72
Content-Type: text/plain; charset=ISO-8859-1

Table is the way to go for all the reasons that Rob mentioned.

>
> This is going to be a small blog to start, but I guess I should always be
>> looking at performance, security, & maintainability right?
>>
>
>
Good way to start is start small and build a strong base around a good
database, good performance practices and tight security you can then build
the cool features as you see fit.

Good thing about performance and security is that there are a ton of site
that outline best practices which means you wont have to re-invent the
wheel.

GL

--0016e64de3cada841504823f4a72--

Re: blog design issue...

am 20.03.2010 21:01:34 von Rene Veerman

i'd go with "tags" over categories, because you can add multiple tags
to a single blog post.

table posts:
postID integer
....

table post_tags:
postID integer
tagID integer
tagPercentageApplies float /* optional, not the industry standard */

table tags:
tagID integer
tagName varchar


On Sat, Mar 20, 2010 at 5:40 PM, Jason Pruim w=
rote:
> 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 look=
ing
> at adding "categories" to my blog posts so I can organize my drivel into
> something that looks somewhat professional, or at the very least, organiz=
ed
> 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 th=
ere
> put "Personal", "Business", "Crap I found funny" =A0Basically 1 database =
field
> for all the categories I decide to use. OR should I go the other route an=
d
> 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 kno=
w
> 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
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php