Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


best practice for storing tags in a database using -'mysql,performance,optimization,tags,structure'


best practice for storing tags in a database  using -'mysql,performance,optimization,tags,structure'

I developed a site that uses tags (key words) in order to categorize photographs.
Right now, what I have in my mysql database is a table with the following structure:

image_id (int)
tag      (varchar(32))


Every time someone tags an image (if the tag is valid and has enough votes) it's added to the database. I think that this isn't the optimal way of doing things since now that I have  5000+ images with tags, the tags table has over 40000 entries. I fear that this will begin to affect performance (if it's not already affecting it).

I considered this other structure thinking that it'd be faster to fetch the tags associated to a particular image but then it looks horrible for when I want to get all the tags, or the most popular one for instance:

image_id (int)
tags     (text) //comma delimited list of tags for the image


Is there a correct way of doing this or are both ways more or less the same?
Thoughts?

Thanks in advance for all your support
    

asked Sep 7, 2015 by rajesh
0 votes
7 views



Related Hot Questions



Government Jobs Opening


...