CREATE TABLE `wbtag` (
  `tagid` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `namespace` char(20) NOT NULL DEFAULT '',
  `tag` varchar(200) NOT NULL DEFAULT '',
  `created` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `changed` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `enabled` tinyint(4) NOT NULL DEFAULT 0,
  `deleted` tinyint(4) NOT NULL DEFAULT 0,
  `brief` text NOT NULL DEFAULT '',
  PRIMARY KEY (`tagid`),
  KEY `namespace` (`namespace`),
  KEY `tag` (`tag`)
) AUTO_INCREMENT=1000 COMMENT='Multi purpose tags';

CREATE TABLE `wbtagreference` (
  `mandatorid` int(11) unsigned NOT NULL DEFAULT 0,
  `tagid` int(11) unsigned NOT NULL DEFAULT 0,
  `namespace` char(32) NOT NULL DEFAULT '',
  `xid` int(11) unsigned NOT NULL DEFAULT 0,
  KEY `tagid` (`tagid`),
  KEY `nsx` (`namespace`,`xid`)
) COMMENT='Gerneric tag relation' ;

CREATE TABLE `wbtagappearance` (
  `tagid` int(11) unsigned NOT NULL DEFAULT 0,
  `namespace` char(32) NOT NULL DEFAULT '',
  `xid` int(11) unsigned NOT NULL DEFAULT 0,
  `created` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `tagcount` int(11) unsigned NOT NULL DEFAULT 0,
  KEY `tagid` (`tagid`),
  KEY `nsx` (`namespace`,`xid`)
) COMMENT='Appearance of tags in text';

CREATE TABLE `wbtagview` (
  `trackid` char(32) NOT NULL DEFAULT '',
  `tagid` int(11) NOT NULL DEFAULT 0,
  `counter` int(11) NOT NULL DEFAULT 0,
  `created` datetime NOT NULL DEFAULT '1970-01-01 00:00:00',
  `hint` enum('default','ignore','attack') NOT NULL DEFAULT 'default',
  KEY `tagidx` (`tagid`),
  KEY `trackidx` (`trackid`),
  KEY `created` (`created`)
) COMMENT='List of tag views'
 PARTITION BY RANGE (year(`created`))
(PARTITION `p2026` VALUES LESS THAN (2027));
