what's the best model for any system of tags? for instance, a subject might have N tags, tags and N might be associated with N threads, basically produce a table, tags and posts a table which table tags, I'd the ID of the posts, and also the tag, could be copying many records as the second subject to include this tag, the best idea way of preventing this?

enter image description here


@Quentin, the issue continues, it'll repeat the records within the table publish_tags

CREATE TABLE IF NOT EXISTS `posts` (
  `pid` bigint(22) NOT NULL AUTO_INCREMENT,
  `author` varchar(25) NOT NULL,
  `content` mediumtext NOT NULL,
  PRIMARY KEY (`pid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

INSERT INTO `posts` (`pid`, `author`, `content`) VALUES
(1, 'Andrey Knupp Vital', 'Hello World !');

CREATE TABLE IF NOT EXISTS `tagged` (
  `pid` bigint(22) NOT NULL,
  `tid` bigint(22) NOT NULL,
  PRIMARY KEY (`pid`,`tid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO `tagged` (`pid`, `tid`) VALUES
(1, 1),
(1, 2);

CREATE TABLE IF NOT EXISTS `tags` (
  `tid` bigint(22) NOT NULL AUTO_INCREMENT,
  `tag` varchar(15) NOT NULL,
  PRIMARY KEY (`tid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO `tags` (`tid`, `tag`) VALUES
(1, 'main'),
(2, 'hello');

Make use of a junction table

It'll have a minimum of two posts. "Posts" and "Tags" using the primary key being defined over the set of them (when the database enables it, otherwise another column for that primary key).