How effective can this Tagging solution be?

Posted by Pablo on Stack Overflow See other posts from Stack Overflow or by Pablo
Published on 2010-05-15T00:15:50Z Indexed on 2010/05/15 0:24 UTC
Read the original article Hit count: 558

Filed under:
|
|
|

Im working on an image sharing site and want to implement tagging for the images.

I've read Questions #20856 and #2504150

I have few concerns with the approach on the questions above. First of all it looks easy to link an image to a tag. However getting images by tag relation is not as easy. Not easy because you will have to get the image-to-tag relation from one table and then make a big query with a bunch of OR statements( one OR for every image).

Before i even research the tagging topic i started testing the following method:

This tables as examples:

Table: Image
Columns: ItemID, Title, Tags

Table: Tag
Columns: TagID, Name

The Tags column in the Image table takes a string with multiple tagID from the Tag table enclosed by dashes(-).

For example:

-65-25-105- 

Links an image with the TagID 65,25 and 105.

With this method i find it easier to get images by tag as i can get the TagID with one query and get all the images with another simple query like:

SELECT * FROM Image WHERE Tags LIKE %-65-%

So if i use this method for tagging,

How effective this is?

Is querying by LIKE %-65-% a slow process?

What problems can i face in the future?

© Stack Overflow or respective owner

Related posts about tagging

Related posts about php