实验室的项目,需要做对用户发布的主题进行打标签的功能,纠结甚久,实现思路如下: 一、数据库表的设计 1.tag表 create table qa_tag(tag_id int primary key auto_increment,tag_name varchar(32) not null,tag_time timestamp not null default CURRENT_T
实验室的项目,需要做对用户发布的主题进行打标签的功能,纠结甚久,实现思路如下:
一、数据库表的设计
1.tag表
create table qa_tag
(
tag_id int primary key auto_increment,
tag_name varchar(32) not null,
tag_time timestamp not null default CURRENT_TIMESTAMP,
refered_cnt int not null default 0,
user_id int not null,
unique (tag_name),
constraint foreign key (user_id) references user_info(user_id)
);
2.topic表
create table qa_topic
(
topic_id int primary key auto_increment,
topic_title varchar(128) not null,
topic_body text not null,
topic_time timestamp not null default CURRENT_TIMESTAMP,