What's the best way to set up a tagging system?
April 24, 2006 10:46 PM
Subscribe
Database experts: I'm setting up a tagging system for a site I run. What's the most efficient way to go about it?
As part of the next version of the mp3 hosting site I run, I want to give users the ability to tag each mp3 they upload with various keywords that people can search later on down the track, much like we can do here with threads. I'd like to know what the general consensus is on the best method of setting something like this up, and how best to implement it.
I thought of making a table, say 'tags', and in that have one new record for each tag a file has. For instance, a user uploads an mp3 and the site assigns it the id '12'. The user selects, from a predetermined list, some tags that best describe the file he's uploading: 'comedy', 'diy', and 'modern french literature'. Three new records are created in the 'tags' table which correspond to those three tags, ie:
id | tagid | fileid
-------------------
1 comedy 12
2 diy 12
3 mfl 12
As more files are added and tagged, records are created for those files too, and eventually we have a 'tag' table with a trillion records which we can interrogate at our leisure.
Is this the best / most efficient way to do this?
posted by Savvas to computers & internet (11 comments total)
posted by paulsc at 11:04 PM on April 24, 2006