I have heard about a couple of methods to implement marking utilizing a mapping table between TagID and ItemID (is sensible in my experience, but will it scale?), adding a set quantity of possible TagID posts to ItemID (appears like an awful idea), Keeping tags inside a text column that's comma separated (sounds crazy but tend to work). I have even heard someone recommend a sparse matrix, however how can the tag names grow beautifully?

Am I missing a best practice for tags?

Three tables (one for storing all products, one for those tags, and something for that relation between your two), correctly indexed, with foreign secrets set running on the proper database, should work nicely and scale correctly.

Table: Item

Posts: ItemID, Title, Content

Table: Tag

Posts: TagID, Title

Table: ItemTag

Posts: ItemID, TagID

If you work with a database that supports map-reduce, like couchdb, storing tags inside a plain text area or list area is definitely the easiest way. Example:



  reduce: function(secrets,values)

Running this with group=true will group the outcomes by tag title, as well as return a count of the amount of occasions that tag was experienced. It's much like counting the occurrences of the word in text.

Make use of a single formatted text column[1] for storing the tags and employ a competent full text internet search engine to index this. Else you'll encounter scaling problems when attemping to implement boolean queries.

If you want particulars concerning the tags you've, you may either keep an eye on it inside a incrementally maintained table or operate a batch job to extract the data.

[1] Some RDBMS even give a native array type which can be better still suited to storage by not requiring a parsing step, but could potentially cause issues with the entire text search.

Agreed with Yakkov or you'll next question is going to be this.

I have always stored the tags inside a separate table after which were built with a mapping table. Obviously I have never done anything on the really massive either.

Getting a "tags" table along with a map table causes it to be pretty trivial to create tag clouds &lifier such as you're able to easily come up with SQL to obtain a listing of tags with counts of methods frequently each tag can be used.