PHP code: ######################################## #1、关键字分类表, 用于对关键字的分类管理 ######################################## # This table defines a community tag_cates ######################################## drop table if exists 'tag_cates'; create table 'tag_cates' ( 'id' int not null auto_increment, #ID号,唯一 'cate' varchar(50) not null, #key_word所属于类别 'key_word' varchar(50) not null, #keyword 'tag_id' int not null, #外键 constraint fk_cate_tag foreign key('tag_id') references tags('id'), primary key ('id') )ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
######################################## #1、关键字分类表, 用于对关键字的分类管理 ######################################## # This table defines a community tag_cates ######################################## drop table if exists 'tag_cates'; create table 'tag_cates' ( 'id' int not null auto_increment, #ID号,唯一 'cate' varchar(50) not null, #key_word所属于类别 'key_word' varchar(50) not null, #keyword 'tag_id' int not null, #外键 constraint fk_cate_tag foreign key('tag_id') references tags('id'), primary key ('id') )ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
PHP code: ######################################## #2、关键字索引表,用于对关键字的统计 ######################################## # This table defines a community tags ######################################## drop table if exists 'tags'; create table 'tags' ( 'id' int not null auto_increment, #ID号,唯一 'key_word' varchar(50) not null, #keyword用于查询 'num' int default '0', #记录该keyword出现的次数 primary key ('id') )ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
######################################## #2、关键字索引表,用于对关键字的统计 ######################################## # This table defines a community tags ######################################## drop table if exists 'tags'; create table 'tags' ( 'id' int not null auto_increment, #ID号,唯一 'key_word' varchar(50) not null, #keyword用于查询 'num' int default '0', #记录该keyword出现的次数 primary key ('id') )ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
PHP code: ######################################## #3、用户关键字索引表,用于记录关键字的相关信息 ######################################## # This table defines a community user_tags ######################################## drop table if exists 'user_tags'; create table 'user_tags' ( 'id' int not null auto_increment, #ID号,唯一 'tag_id' int not null, #tag_id 'user_id' int not null, #原作者的id 'url' varchar(50) not null, #该tag所属的文章连接url 'created_at' datetime default null, #关键字产生的时间 constraint fk_tag_user foreign key('tag_id') references tags('id'), constraint fk_user_tag foreign key('user_id') references users('id'), primary key ('id') )ENGINE=InnoDB DEFAULT CHARSET=utf8;
######################################## #3、用户关键字索引表,用于记录关键字的相关信息 ######################################## # This table defines a community user_tags ######################################## drop table if exists 'user_tags'; create table 'user_tags' ( 'id' int not null auto_increment, #ID号,唯一 'tag_id' int not null, #tag_id 'user_id' int not null, #原作者的id 'url' varchar(50) not null, #该tag所属的文章连接url 'created_at' datetime default null, #关键字产生的时间 constraint fk_tag_user foreign key('tag_id') references tags('id'), constraint fk_user_tag foreign key('user_id') references users('id'), primary key ('id') )ENGINE=InnoDB DEFAULT CHARSET=utf8;