php - How effective can this Tagging solution be? -


I am working on an image sharing site and want to implement tagging for images.

I read the question and

I have some concerns from the point of view of the above. First, it seems easy to link an image with a tag. However getting images by tag relationship is not easy. Not easy because you have to get an image-to-tag relationship from a table and then do a big query with a bundle or statement (for one or every image).

Before I even research tagging topics I started testing the following method:

This table as an example:

  table : Many of the  tag ID  tags  columns  tags in the table  tag column: tag id:  tag, tag table: tag column, tag id, < image  / Strong>  

  -65-25-105-  

For example:

Tag ID links an image with 65,25 and 105.

With this method, I find it easy to get the picture by tag because I get the TagID with a question and get all the images from another simple query like:

I use this method for tagging,

how to do Is it effective?

Is a slow process like inquiry-% -65-%?

What problems can I face in the future?

You need 3 tables for this.

  table: image column: image, item id, title table: imagegag column: image id, tagad table: tag column: tag id, name  

then To get all the images for a tag:

  SELECT ImageId, Title FROM Image_Tag LEFT JOIN Image Using (ImageId) Where TagId = $ TagId  

This is a specific way of handling multiple-to-many relationships in relational databases, you will probably benefit from reading about

editing: I think that it will be appreciated by you Bhit knew already Among other questions, why would I explain further. The biggest problem is that I am adopting it, you can not take advantage of indexing your ID column, which makes your queries less efficient. It also seems that it will be clumsy to update. I would suggest not trying to do this like this, try to use at least 3 table solutions. Once you are "click" for me you will thank me.


Comments