Contribute  :  Support  :  Downloads  :  Forum  :  Links  :  Polls  :  Calendar  :  Directory  :  Advanced Search  
Geeklog The Ultimate Weblog System
Welcome to Geeklog
Friday, May 16 2008 @ 03:43 AM EDT
   

Geeklog and Categories

GeeklogI have been chomping at the bit to rework Geeklog a bit to allow the use of hierarchical (nested) categories for stories, links, etc. Implementing it won't be very hard as it is nothing more than a basic cataloging system (categories, sub-categories and items). However, my implementation plans are more generic. Find out my plans to implement this by clicking 'read more'

Implementing hierarchical categories isn't anything new. Yahoo, Google and Excite and crew have been doing it for years. What I want to do is show you the basic implementation for a cataloging system and how I want to extend it just a bit so that this system is really flexible.

Typical Implementations

First, let me cover the basic data structures for such a system. Below are three tables with the most basic attributes needed:

Table: category
Fields:
cg_id mediumint(8) NOT NULL auto_increment,
cg_name varchar(64) NOT NULL,
cg_descr varchar(255),
cg_parent_id mediumint(8),
Primary Key: cg_id
Description: This is the category table. This is a self-referencing table that supports nested categories through the use of the cg_parent_id field which will point to the parent category.

Table: category_item
Fields:
item_id mediumint(8) NOT NULL auto_increment;
item_name varchar(64) NOT NULL
item_cg_id mediumint(8) NOT NULL
--other specific item data--
Primary Key: item_id
Description: This isn't any different from a couple existing Geeklog tables such as stories and links. They are tied to a category through item_cg_id

The Twist

First let me state that what I'm about to propose isn't an original idea. However, I will say that I don't think any of the current weblogs have implemented their categories this way which would make this a bit unique to Geeklog.

The main problem with the above table structures is that we'd have to implement a seperate category table for each 'thing' that needs them. For example we'd need a story_categories and a link_categories. They'd essentially be the same tables structure-wise and only differ in the data they hold. We can prevent having to do this by adding an additional catalog table: Table: catalog
Fields:
ctg_id mediumint(8) NOT NULL auto_increment
ctg_name varchar(64) NOT NULL
ctg_descr varcahr(255)
ctg_gl_core tinyint(1) DEFAULT 0 NOT NULL
Primary Key: ctg_id

Such a table would allow you to create a catalog for each 'thing' needing heirarchical categories. For example, in Geeklog we'd have one catalog for stories and one for links. By doing this, however, we need modify our original category and add a cg_ctg_id that ties a category to a catalog.

What makes this really flexible is we can then create an administrative interface that allows you to quickly administer catalogs and their categories. Furthermore, this implementation lends itself for use in plugins (I can see a Geeklog shopping cart application using this).

What is that ctg_gl_core field for? Well, Geeklog will have a few default catalogs (for example stories). Obviously if you delete the stories catalog Geeklog will cease to function as expected. So for any catalogs that ship as a part of a Geeklog release we will set the ctg_gl_core field to 1 to prevent users from editing or deleting that category. If you were to create a new catalog via the administrative interface that fielf would automatically be set to 0 allowing you full administrative control. This is very similar to how we implemented groups with he grp_gl_core field.

So, does this sound reasonable? Can this be improved? Is it too complicated?

Story Options

Geeklog and Categories | 3 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Sounds like this is exactly what i need!
Authored by: chrispee on Tuesday, January 15 2002 @ 11:34 AM EST
Heyas,

After reading this 3 times i think this is exactly what i am looking for :-)

My brain isn\'t very cooperative when it comes to database abstractions, but if this works the way i think, it would be awesome.

And thanks for not using the word \"entity\" ;-)

#--
chrispee
.insane in the mainframe.
sections?
Authored by: ezra on Wednesday, January 16 2002 @ 01:26 AM EST
Hmmm. Honestly, I can\'t fully follow the database logic and I\'d like to pull back to pseudocode or flowcharting. :-) But I think maybe you are complicating things by trying to be too elegantly OOP, so that you can bolt the same structure onto every \'thing.\' I\'m not sure that\'s necessary. Why can\'t the structures be different for different types of things? It\'s not as if the display is the same; categorized links should look very different than categorized weblog entries, no? Or am I just being dense?

I also wonder if you need a full hierarchical system with infinite levels. For many users, couldn\'t you accomplish the same sort of thing by creating sections, i.e., only a one-deep hierarchy? I\'d be quite satisfied with that. Example:
Section: Politics
Weblog entries w/comments
Links
Calendar of political events
Other stuff
Section: Weblog nattering
Entries w/comments
Links
Calendar of GL development deadlines
Other stuff
Section: Computer dating
Weblog entries w/comments
...and so forth.

This would also enable you to empower moderators who are in charge of their sections of entries, links, etc., etc. It would be nice if this could maybe go down another level or two (subsections and subsubsections) but not essential.

In my own case, academia (I teach journalism), sections would allow Geeklog to be used much more easily. It would be scalable for a single course, a department, a college, on up to being a full university system.

As it stands right now, if I want to use one installation of Geeklog as the web home for several different classes --which it should be able to do -- I\'m going to have to do a lot of fudging, e.g., using GL topics as a way to cordon off the different courses.

And then there\'s the issue of user privileges being horizontal. . . .

It\'s late and I\'m not sure this has made any sense. Should I try it again in the morning, or do you catch the drift?

-ES
sections?
Authored by: Tony on Wednesday, January 16 2002 @ 07:04 AM EST
Am I being complicated? I don\'t think so. Nothing I mentioned here even relates to OOP so I\'m not following your comment there.

Even for a single nested section you need to know who the parent is, right. So regardless you\'ll need a field that represents who the parent is. To me this isn\'t complicated...just more abstract. I suppose some people could see abstraction as a complicated thing but it really isn\'t.

Also, this is much more flexible than creating new structures for everything that needs to be categorized. Why create 2,3 even 4 tables that all represent pretty much the same thing?

If you can, be more specific about why you think this is complicated because I just don\'t see it that way.

-----
The reason people blame things on previous generations is that there\'s only one other choice.