开发者

Handling tags like categories?

I want to use tags in my site. How to handle开发者_Python百科 the tags most efficiently?

Is it OK to put every tag in a table (like categories) and than in the post just reference them with their id? (like in wordpress)


In general, having a lookup table for tags and then referencing them by ID is a good idea, yes. Among other things, it saves storage space - you only need to store the string version of a tag once; the numerical id will almost certainly be shorter.

Tags are generally a many-to-many relation, and thus usually use a layout that consists of 3 tables: the content items table, the tags table, and then a "content-to-tag" mapping table. The first two are fairly straightforward; the third is merely a table where each row is a link between a content item and a tag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜