Page 1 of 1

Looking for a Tag recipe

Posted: Mon May 07, 2007 10:42 pm
by bert4
Hi Foumites,

I am thinking about implementing a Tag Keyword kinda thing for a website.

I am able to do simple things with MySql, getting stuff from tables, making categories assign items to categories etc, but this is beyond me.

A simple tag system that I would be able to make;

Just add tags to items, put the tags in a table and when a tag is clicked, search for the tags in the items.

But now the thing that I can't work out....

Suppose those items can belong to users, groups, subgroups etc (a variable subdivision).. and you want to show the tags only for the user, group or subgroup, how can you set up something like that?

Similar to Flickr. 8)

The only thing I can come up with is to create a tag table for each user, groups or subgroup, and assemble the "master table of tags" from all those tables where appropriate, or something, but this gets very complicated, and uses lots of code and processor time.


Does anyone have an idea or can point me in the right direction?

Thanks

Posted: Tue May 08, 2007 5:41 pm
by califdon
I wouldn't create multiple tables. What kind of a schema do you have in mind? What do you mean by "items" and "things"? It's hard to know what you are really trying to do or how you want to accomplish it.

I haven't tried to construct this kind of a lookup, but I think I would probably start with a schema something along the lines of this:

tblReferences:
id INT()
URL VarChar()
tags Text
group VarChar()

... and use full-text search.

Another approach might be:

tblTags:
Tagid INT()
tag VarChar()
group VarChar()

tblReferences:
Refid INT()
URL VarChar()

tblLinks :
Tagid INT()
Refid INT()

Posted: Wed May 09, 2007 10:55 am
by bert4
Hi Califdon,

thanks for thinking with me.

Here is something I did:

Ubud

Very simple. The item has a text string with comma separated tags, easy to search with a "LIKE" statement.

Similar to your first suggestion.

It would also be simple to filter this for groups/categories where an item belongs to.

If you would make a tag cloud however, you would have to loop through all the records and split the tags into an array, and finally do some tossing around to have a correct representation of the tag cloud. Can do, no problem.

If you have little records, its doable, but my guess is that if you have 100.000 items with each 10 tags things get slow and need lots of memory. And if you have 10.000 people on your site who request this tag cloud, you may have a bit of a problem. I think.

But Take Flickr. You upload a picture, give it a few tags, and these tags are available for groups you belong to, your self, and your photo sets and whatever more.

I don't think that Fllickr searches every time through the whole database of pictures when a tag cloud is requested....

I am just wondering if there is some sort of data structure that would prevent things to become very memory and processor intensive when the database grows. I can't think of anything.