doujiekeyan0622 2013-01-25 23:53
浏览 17

WordPress / mySQL如何将关键字与帖子关联[复制]

Possible Duplicate:
How do you recommend implementing tags or tagging

I'm learning some php/mysql and I had this thought on how it is wordpress associates a tag with a post, more so, a tag with several posts, without repeating the tag itself in several different Cells of each Post/Line-in-mysql

Thank you

  • 写回答

2条回答 默认 最新

  • duanji9311 2013-01-26 00:00
    关注

    Not specific to wordpress, but any relational database architecture. Basically you have a table with content and a table with tags. Then to bridge the two you have a table that associates one to the other.

    Here's a link to a more in depth description: http://www.anchor.com.au/hosting/support/CreatingAQuickMySQLRelationalDatabase

    So you have a content table with a primary key id. You also have a tags table with its own primary key id. Your relational table has both of those ids simply like so...

    ----------------------------
    | id | content_id | tag_id |
    ----------------------------
    

    You can then use joins of many varieties to select content based on tags and so on.

    This subject is WAY too in depth for stack overflow though. It is suggested you do some basic google searches for mysql database structures, relational tables, and joins. The list could go on for days.

    Any specific questions? I may update if you ask.

    评论

报告相同问题?