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
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.
The php code and the MySQL query can be found on the wp-includes/taxonomy.php
file, specially the wp_set_object_terms()
function: http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/taxonomy.php#L2147